问题描述
我正在尝试在使用StateServer时在ASP.NET会话中存储Linq Entity对象(当使用Linq to SQL时)。我收到一个错误,因为EntitySet类不可序列化。我试图在会话中存储的一个实体类与另一个类有1到n的关联,因此这里使用的是EntitySet。由于对象在存储在StateServer中时首先进行二进制序列化,但问题是EntitySets不是二进制序列化的。
我也尝试过将序列化模式设置为单向的选项,但这也不起作用(当然,因为我不在这里使用WCF而且我不需要DataContracts)
那么有没有办法序列化Linq Entity对象或使用StateServer或SQLServer将它们保存在Sessions中?
I am trying to store Linq Entity objects (when using Linq to SQL) in the ASP.NET session when using StateServer. I get an error because EntitySet class is not serializable. One of my entity classes which I am trying to store in session has 1 to n association with another class, hence the EntitySet is being used here. Since objects are first binary-serialized when they get stored in StateServer but the problem is that EntitySets are not binary serializable.
I have also tried the option of setting the Serialization Mode to Unidirectional but that doesn't work either (of course coz i am not using WCF here and i don't need DataContracts)
So is there any way to serialize Linq Entity objects or saving them in Sessions using StateServer or SQLServer?
推荐答案
这篇关于在ASP.NET中将Linq对象序列化为StateServer会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!