Reputation: 1621
How can I store a LINQ query (i.e. of type IQueryable<T>
) in SQL Server session state or any other State Server?
Upvotes: 3
Views: 3788
Reputation: 28728
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
Upvotes: 3
Reputation: 3535
You can serialize/deserialize manually the Expression that is associated to IQueriable using the visitor
Or check here: http://archive.msdn.microsoft.com/exprserialization
Upvotes: 2
Reputation: 292555
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
Upvotes: -1