LINQ to Entities does not recognize the method 'Int32 IndexOf(System.String, System.StringComparison)' method

后端 未结 4 1792
小蘑菇
小蘑菇 2021-02-19 22:30

I have executed a linq query by using Entityframework like below

GroupMaster getGroup = null;
getGroup = DataContext.Groups.FirstOrDefault(item => keyword.Ind         


        
4条回答
  •  走了就别回头了
    2021-02-19 23:05

    You really only have four options here.

    1. Change the collation of the database globally. This can be done in several ways, a simple google search should reveal them.
    2. Change the collation of individual tables or columns.
    3. Use a stored procedure and specify the COLATE statement on your query
    4. perform a query and return a large set of results, then filter in memory using Linq to Objects.

    number 4 is not a good option unless your result set is pretty small. #3 is good if you can't change the database (but you can't use Linq with it).

    numbers 1 and 2 are choices you need to make about your data model as a whole, or if you only want to do it on specific fields.

    Changing the Servers collation: http://technet.microsoft.com/en-us/library/ms179254.aspx

    Changing the Database Collation: http://technet.microsoft.com/en-us/library/ms179254.aspx

    Changing the Columns Collation: http://technet.microsoft.com/en-us/library/ms190920(v=sql.105).aspx

    Using the Collate statement in a stored proc: http://technet.microsoft.com/en-us/library/ms184391.aspx

提交回复
热议问题