在ASP.NET中将Linq对象序列化为StateServer会话状态 [英] Serializing Linq objects to StateServer session state in ASP.NET

查看:74
本文介绍了在ASP.NET中将Linq对象序列化为StateServer会话状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在使用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?

推荐答案

我遇到了同样的问题。我现有的应用程序使用手工编码的实体和适配器以及SqlServer会话状态。我正在尝试将其转换为LINQ,它似乎工作得很漂亮,直到我尝试保存到分布式会话。

有没有人对此进行修复,或者如果我想使用StateServer或SqlServer会话构建应用程序,是否需要返回编写自己的实体?
I am having the same issue.  My existing app use hand-coded entities and adapters and SqlServer session state. I'm attempting to convert it to LINQ and it seems to work beautifully right up until I try and save to distributed Session. 

Does anyone have a fix for this, or do I need to go back to writing my own entities if I want to build an application with StateServer or SqlServer session?


这篇关于在ASP.NET中将Linq对象序列化为StateServer会话状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆