3

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.

EricGS
  • 1,323
  • 2
  • 17
  • 42

1 Answers1

1

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?

Community
  • 1
  • 1
andleer
  • 22,388
  • 8
  • 62
  • 82
  • so far i haven't been able to find a workaround on EF, so im changing the collations on the specific fields i need to perform a search, the problem is that now i need validation over unique fields – EricGS May 16 '14 at 14:18