I have a table with a column of type varchar where the majority of rows have numerical looking values, that is, each string contains nothing but the digits 0 through 9.
SQL like this works perfectly, implicitly type-casting varchar to a numeric for comparisons:
SELECT * FROM t WHERE n >= 200 AND n <= 500;
However, I'm stuck using C#/.NET's LINQ to Entity Framework and am getting an error message that "LINQ to Entities does not recognize the method 'Int64 Parse(System string) method, and this method cannot be translated into a store expression."
var results = from n in context.t
let n_asLong = long.Parse(n)
where ( n != null && n_asLong >= 200 && n_asLong <= 500 )
select n_asLong;
What's the right way to encode the type-change into the comparison?
Thanks,
Walt Stoneburner
wls@wwco.com