ignore accents on search using linq to entities (EF)

asp.net-mvc-4 entity-framework-6 linq

Question

i need to perform a search on over a table whit a string field that contains accents (á, ì, ü, etc) im using EF 6

first i try i direct search like:

 var listaResultados = db_hms.Topology
                .Where( t => t.is_active == true && ((t.display_name.Contains(busqueda))||(t.detail.Contains(busqueda))))

but this is accent sensitive, then i try this:

t.display_name.IndexOf(busqueda, StringComparison.InvariantCultureIgnoreCase) >= 0

but is not supported on linq to Entities

any other idea please pd: i need to perform the search on a "Contains" way, not a starts whit.

1
3
5/15/2014 12:09:42 PM

Accepted Answer

These comparisons will depend on collation you selected when creating your SQL Server Database. I don't know if the EF has any workarounds but you can possibly get around this using a stored procedure to invoke something along the lines of this:

How do I perform an accent insensitive compare (e with è, é, ê and ë) in SQL Server?

1
5/23/2017 11:51:00 AM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow