开发者

Serializing IQueryable<T> to session state server

How can I store a LINQ query (i.e. of type IQueryable<T>) in SQL Server session state or any oth开发者_Python百科er State Server?


You can't serialize the IQueryable but you may be able to serialize the expression tree which generates that IQueryable. Check out the following question and associated MSDN link.

Can you Pass Func<T,bool> Through a WCF Service?

http://archive.msdn.microsoft.com/exprserialization


You can serialize/deserialize manually the Expression that is associated to IQueriable using the visitor

Or check here: http://archive.msdn.microsoft.com/exprserialization


As far as I know, most implementations of IQueryable are not serializable, so you can't do that. But anyway, why do you need to do that? If you want to save the results of the query, just call ToList on the query and store the result in the session

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜