Hi Nathan,
I don't think there are currently good ways to implement your #1 and
#2. For #3, I don't know if it would really make the query less
efficient - compiling an expression is a very similar effort as
interpreting it (once), I think.
There is a fourth approach; when you traverse the Select expression
and you encounter the subquery, translate it back into an expression
by using the ReverseResolvingExpressionTreeVisitor and manually
building up a Select method call:
- Apply the visitor to the Selector ([c].LastName) and the subquery's
query source ([c]) to get a LambdaExpression that you can use as a
selector for Select method (c => c.LastName).
- Use the MainFromClause's FromExpression as the Select method's
source parameter and build a MethodCallExpression with the
Enumerable.Select method. You get [a].Contacts.Select(c =>
c.LastName).
- Then, apply the visitor again to that whole expression, using the
outer query's query source as an input parameter ([a]). You get a =>
a.Contacts.Select(c => c.LastName), which you can compile and execute
against an Account object.
However, I think that in your case, the simplest way would indeed be
to completely disable subquery detection. I'll wait for Michael to
confirm this, but I guess he would accept a patch that adds an
overridable "ProcessSubQueries" method to ExpressionTreeParser.
re-linq was originally designed for providers that would also
translate such subqueries into a query to some external system.
However, if more people need a way to get back the original expression
from a QueryModel, we could probably build this into re-linq. Again -
after some more discussion about how to tackle this -, I guess, we'd
accept patches :)
Best regards,
Fabian
> --
> You received this message because you are subscribed to the Google Groups
> "re-motion Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
re-motion-use...@googlegroups.com.
> To post to this group, send email to
re-moti...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/re-motion-users.
> For more options, visit
https://groups.google.com/d/optout.