Compiled Linq & String.Contains

后端 未结 2 825
暗喜
暗喜 2021-01-20 19:05

I\'m using Linq-to-SQL and I use compiled Linq for better performance.

I have users table with a INT field called \"LookingFor\" that can have the follo

相关标签:
2条回答
  • 2021-01-20 19:32

    I'm facing the same problem. I have managed for now just one workaround for this problem. Instead of using

    u.LookingFor.ToString().Contains(lookingFor)
    

    I've used

    u.LookingFor.ToString().IndexOf(lookingFor) >= 0
    
    0 讨论(0)
  • 2021-01-20 19:38

    You're performing operations on the lookingFor argument that cannot be translated to SQL. I'm actually surprised that this works when not compiling the query.

    If it's possible, I suggest that you change your database to make this query easier. Create a table to store the LookingFor property for users. Or you can change the datatype of lookingFor to a string, which has less of an impact on the database design.

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