序列化包含 StateServer 的 linq2sql 对象的对象
我目前正在尝试序列化托管在使用 SessionState = Stateserver 的服务器上的 Web 项目的对象。
我将该对象标记为[Serialized]
,但该对象包含一个属于 LINQ2SQL DataContext 一部分的对象。我已经读到可以使用 DataContractSerializer 序列化这个序列化,但是正确的位置在哪里?
我是否只需要实现 ISerializeable
并在 GetObjectData()
函数内序列化我的 NodeObject 并将其添加到 SerializationInfo
中?有人对一种好方法有什么想法吗?
I am currently trying to serialize an object for a webproject that is hosted on a Server that uses SessionState = Stateserver.
I marked the object as [Serializable]
but the object contains an object that is part of a LINQ2SQL DataContext. I already read that it is possible to serialize this one with the DataContractSerializer
but where is the correct place to do that ?
Do I just need to implement ISerializeable
and serialize my NodeObject inside the GetObjectData()
Function and add it to the SerializationInfo
? Any one any ideas about a good approach ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
请找到以下链接。了解 [Serialized] VS DataContractSerializer 之间的区别将很有帮助。请根据您的适合性实施,因为您的项目没有太大差异。
http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacontractserializer-serialization-in-wcf/
Please find the below link. It will be helpful to understand the difference between [Serializable] VS DataContractSerializer. Please implement based on your suitability as there is not much difference in your projcet.
http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacontractserializer-serialization-in-wcf/
现在就做吧。我使用
[Serialized]
标记包含 Linqobject 的对象,并包含ISerialized
接口。DBOItem
是我的 LinqObject需要包含用于反序列化的 Ctor 如下所示:
Done it now. I marked my Objects that contain the Linqobject with
[Serializable]
and included theISerializable
Interface.DBOItem
is my LinqObjectThe Ctor that needs to be included for deserialisation looks like this :