Implementing a provider for this is not that difficult:
var query = from foo in someContext.Foos
where foo.Bar == "bar" && foo.Gaz > 4
select foo;
But if I chain together two operators like so:
var chained1 = (from foo in someContext.Foos
where foo.Bar == "bar"
select foo)
.Where(f => f.Gaz > 4);
or if I did this:
var chained2 = chained1.Take(10);
How would I implement this?
In evaluating the current method call or operator, in the VisitMethodCall
, I visit the instance / object / expression on which the method call is made. That should call VisitConstant
for evaluating / translating / re-writing that instance expression.
Then, in the VisitConstant
if I do this:
if (typeof(IQueryable).IsAssignableFrom(node.Type))
{
_builder.Append((node.Value as IQueryable).ToString());
}
it doesn't work.
How do I get the query text for the previously built query?