Problem with LINQ to Entities and String.StartsWith

后端 未结 1 803
傲寒
傲寒 2020-12-10 00:36

I\'m trying to build a search page using LINQ to Entities, but the following code is giving me a runtime error about l.t.e. not recognising \'Boolean StartsWith(). The code

相关标签:
1条回答
  • 2020-12-10 00:50

    I would guess that EF doesn't support the overload of StartsWith that takes a StringComparison parameter.

    It should support StartsWith, EndsWith and Contains, so maybe you can try:

    dp.LastName.StartsWith(searchTerm)
    

    or:

    dp.LastName.ToLower().StartsWith(searchTerm)
    

    and then make sure that searchTerm is also lowercase.

    0 讨论(0)
提交回复
热议问题