I am writing a LINQ query against the ObjectContext. What I essentially need to do in LINQ to Entities is this (I know this won’t work, but I’m doing it this way to illustrate):
from c in context.Table
where key == int.Parse(c.KeyAsString)
order by int.Parse(c.KeyAsString)
select c
I wasn’t sure if this was possible… anybody know of a way?
Thanks.
try it the other way around. I assume “key” is a variable int so cast that to string by using ToString() and use that to compare with KeyAsString and in the order by don’t use a cast:
if you have trouble with the order by use a method like
ToList()orToArray()to pull the results into memory and there you’ll be able to cast to int or use a custom comparer.