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.

Était-ce utile?

La solution

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?

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top