开发者

Serializing IQueryable<T> to session state server

开发者 https://www.devze.com 2023-03-30 19:01 出处:网络
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 serial

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

精彩评论

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