I am sure that the answer to this question is: βYou cannot do thisβ or βNo, no, you misunderstood ...β, but:
I have a linq class, a thing that will happily accomplish this:
var thingsWithAandB = from t in db.things
where t.propA.HasValue && t.propB.HasValue
select t;
But I do it a lot, and therefore I want:
partial class thing
{
public bool hasAandB
{
get
{
return propA.HasValue && propB.HasValue;
}
}
}
and then:
var thingsWithAandB = from t in db.things where t.hasAandB select t;
But, of course, when I do this, I get the error "Can't translate this to SQL." And I understand that this is because calling methods in the middle of SQL queries is not possible, since my code and database are separate.
How to do it? It's impossible?
source
share