Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

linq to sql ExecuteQuery() as IQueryable

ExecuteQuery() method returns an IEnumerable but is there a way to make it return IQueryable?

like image 802
codette Avatar asked Dec 29 '22 20:12

codette


1 Answers

Well, you can call AsQueryable, but it won't do any good. The problem is that when you use ExecuteQuery, the query isn't composable because LINQ to SQL doesn't "understand" it as such.

One of the core purposes of IQueryable<T> is to allow the various aspects of a query to be composed together and then LINQ to SQL can convert them into a single SQL query. That just doesn't work when one of the bits of the query is effectively opaque.

like image 187
Jon Skeet Avatar answered Jan 01 '23 17:01

Jon Skeet