How can I make my Linq to SQL query logic execu开发者_运维百科te on the server?
I have a created a Linq query and returned it as an IEnumerable. Subsequent operations on the query such as .Count() or .Take(5) are evaluated on the client in CLR, rather than on the server.
Converting to IEnumerable will cause the query to be executed - as a result the data is now on the client side.
If you want to execute paging on the server side, you should perform those operations while it is still a late executing IQueryable.
IEnumerable was the problem. Returning the Linq.DataQuery as an IQueryable allows Linq to SQL to add additional operations to the query. Figured this out as I was describing the problem.
精彩评论