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

后端 未结 5 1730
谎友^
谎友^ 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:26

    I haven't got a clue if this will work over Linq to EF or not but presuming that they mapped the Math operations, this might solve your need:

    record.ConsecutiveNumber / Math.Pow(10, Math.Truncate(Math.Log10(record.ConsecutiveNumber) - 3)) == 1234
    

    This is basically dividing the number by a power of 10 just big enough to leave the first 4 digits.

    I know this is very hacky and inefficient even if it works, but there you go. :)

提交回复
热议问题