ASP.NET MVC Search Page - Integer StartsWith On Linq + EF4

后端 未结 5 1706
谎友^
谎友^ 2021-01-03 16:58

So, in my last post I was asking how to build a dynamic search filter using LINQ and EF4 (See Here) and finally came up with the solution of building the expression as a str

5条回答
  •  -上瘾入骨i
    2021-01-03 17:24

    You can use the SqlFunctions.StringConvert method. It requires a double (or decimal) so you'll have to cast your int ConsecutiveNumber.

    Replace:

    record.ConsecutiveNumber.ToString().StartsWith("1234")
    

    With:

    SqlFunctions.StringConvert((double)record.ConsecutiveNumber).StartsWith("1234")
    

提交回复
热议问题