Ignoring accents while searching the database using Entity Framework

后端 未结 4 1673
长发绾君心
长发绾君心 2020-12-11 15:23

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 s

4条回答
  •  不知归路
    2020-12-11 15:45

    I know that is not so clean solution, but after reading this I tried something like this:

    var query = this.DataContext.Users.SqlQuery(string.Format("SELECT *  FROM dbo.Users WHERE LastName like '%{0}%' COLLATE Latin1_general_CI_AI", parameters.SearchTerm));
    

    After that you are still able to call methods on 'query' object like Count, OrderBy, Skip etc.

提交回复
热议问题