开发者

Read and write .NET Objects in SQL Database without serialization

I have a small query. I need to create a Caching Service of my own that will write and read .NET Objects to and from the Database. Now, I have achieved that with the help of Binary Serialization. But the Problem is I need to deliberately marked my objects as [Serializable], which makes me think that what if someone will try to add an object which is not marked as [Serializable].

Thus, I need to find a way to read and write Objects to Database without Serialization.

I have one thought too.. As we all know Session can store any o开发者_如何学Cbject in it. Now, we can make sessions to be stored in the DB, outproc. What mechanism it uses to store these objects without serializing or deserializing.

Any help will be highly appreciated.

Thanks. M.B


If it's saving to disk in any manner, it is serializing the state in some manner. You can easily serialize with XML to the database on your own.

Check out the System.Xml.Serialization namespace.


To serialize an object means to take the information from that object and store it to some form of permanent store in a standard way so that the object can later be effectively reconstructed via that information. Any object which is going to be written out to a database should be serializable. If it is being stored without some form of serialization process, then when deserialization is attempted the object may possibly be read back in a strange or inconsistent state.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜