When writing expressions, it is much easier if the expression can be used both in-memory and in Linq to NHibernate without being modified.
Imagine the following Expression
I should be able to write all of the following queries. I'm using some pseudo code here, but imagine that everything in within is single NH session and I'm using LinqKit to compose expressions
In my test cases above, r1, r2, r3, and r5 all work fine. r4 explodes if specificA.Prop2 is null because a.Prop2.ChildProp1 can't be reduced and a.Prop2 != null is not short-circuiting boolean expression.
ReLinq is used to partially evaluate the expression. So a.Prop2 != null should be reduced to null != null which can be evaluated in memory. a.Prop2.ChildProp1 reduces to an expression tree that contains an exception node because a.Prop2 is null.
When writing expressions, it is much easier if the expression can be used both in-memory and in Linq to NHibernate without being modified.
Imagine the following Expression
I should be able to write all of the following queries.
I'm using some pseudo code here, but imagine that everything in within is single NH session and I'm using LinqKit to compose expressions
In my test cases above, r1, r2, r3, and r5 all work fine.
r4 explodes if
specificA.Prop2
isnull
becausea.Prop2.ChildProp1
can't be reduced anda.Prop2 != null
is not short-circuiting boolean expression.ReLinq is used to partially evaluate the expression. So
a.Prop2 != null
should be reduced tonull != null
which can be evaluated in memory.a.Prop2.ChildProp1
reduces to an expression tree that contains an exception node becausea.Prop2
isnull
.