开发者

Persistence of deferred execution linq expressions

We're trying to serialize some data, and one of the items in a col开发者_运维问答lection is a "deferred execution linq statement" (actually it's the result of a Concat call on a collection).

The problem is how to persist that object. It doesn't support ISerializable. The actual type is something along the lines of System.Linq.Enumerable.WhereSelectListIterator<>

Just wondering if anyone had run into this before, and what the solution was.


You can call ToList() on the Linq statement; this will gather all of the results and return them in a List<T> which you can then serialize.


If querying the results and serializing them is not an option, you would have to manually serialize the query somehow.

One problem is that there are too many different LINQ query object types. And all these types are internal to the framework. That pretty much locks you down.

There might a solution for your specific case though. If the only type of query you need to serialize is the result of a Concat call, the solution might not be too complex. All depends on the collections you are concatenating and the way you are (or want to) serialize them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜