Ignoring accents while searching the database using Entity Framework

Øyvind Bråthen picture Øyvind Bråthen · Jun 15, 2011 · Viewed 12.2k times · Source

I have a database table that contains names with accented characters. Like ä and so on.

I need to get all records using EF4 from a table that contains some substring regardless of accents.

So the following code:

myEntities.Items.Where(i => i.Name.Contains("a")); 

should return all items with a name containing a, but also all items containing ä, â and so on. Is this possible?

Answer

stuartd picture stuartd · Jun 15, 2011

If you set an accent-insensitive collation order on the Name column then the queries should work as required.