Hey, I am trying to create an Expression<Func<T, bool>>
in which a string property is converted/cast to a DateTimeOffset so that DateTimeOffset operations can be performed on it.
We are using Linq2SQL as our data provider, which does support converting strings to the SQL equivalent of DateTimeOffset. Ideally I want the expression to be evaluated directly inside the IQueryable data source, and not in memory as an IEnumerable.
See below for an example of what I have tried to far:
public class MyClass
{
public string MyValue;
}
Expression<Func<MyClass, bool>> filter = mc => DateTimeOffset.Parse(mc.MyValue) > new DateTimeOffset(2007,1,1);
Unfortunately this definition of filter causes an in memory evaluation.