Linq to sql translation to sql of custom method
- by DJPB
hi there
is there a way to translate an expression to sql to use with linq to sql?
for example I have a method that compares two values
example:
MyComparer.Compare(value1, value2, ">") return value1 > value2
MyComparer.Compare(value1, value2, "=") return value1 == value2
MyComparer.Compare(value1, value2, "<=") return value1 <= value2
and i would like a query like
var list = from i in dataContext.items
where MyComparer.Compare(i.value, someValue, "some operator")
select ...
this won't work because, obviously, MyComparer doesn't translate to sql
maybe this is a twisted question, but how can i translate this method to sql or is this possible?
tks