Short Version
I want to search a string data type for all numbers between "1000000" and "1009999", and the LINQ query needs to be SQL optimised.
Longer Version
I see many posts for "Contains()", "StartsWith()" and "EndsWith()", but nothing for a number compare.
What I want is the equivalent of SQL like '100____'
, but it must be all numbers, thus like '100[0-9][0-9][0-9][0-9]'
. (The data type is string and can contain non-numeric data.)
What is the LINQ equivalent, that is also SQL optimised, to validate that a string value is only numbers?
I tried .Where(p => p.Value >= "1000000" && p.Value < "1010000")
, but comparison on strings are not accepted (it gives a compile error).
This must be compatible with .NET Core, so .NET Framework solutions like SqlMethods.Like()
and SqlFunctions.IsNumeric()
are out.