Hi, Is this the best way to use a Join for an OrderBy?
If I remove the .Prefetch() part I get an exception:
Inner Exception:
Regards Paul Sinnema Diartis AG This thread was imported from our support forum. The original discussion may contain more detailed answer. |
You can't use AsQueryable method this way: it just wraps underlying IEnumerable to IQueryable by attaching the IQueryable infrastructure to it. When you extend such queryable further and execute it, the provider attached to it will simply compile its expression with Reflection.Emit, but original root there will be enumerable you converted to queryable, i.e. finally it's nearly the same as dealing with enumerable, all the difference is that you (technically) can use an expression describing it. DO4 can't compile a query with IEnumerable.AsQueryable method call: it doesn't have any info about sequence you passed to AsQueryable method, so even if we'd implement best possible support for this, DO would be able only to pass this sequence to server as local collection. So in your case it would work as:
That's it. But this doesn't work - as I just shown, there is no reason to support AsQueryable calls. We provide more explicit API allowing to "push" the collection to server - there is Query.Store<t>(IEnumerable<t> sequence) method. Details: http://goo.gl/SRln Concerning your case: all you need is to move .Prefetch(...) calls to the tail of call chain. Since they turn queryable into enumerable, they must be in the end. |