Is there anyway to stick objects which are decorated with DataContract
attributes but not decorated with Serializable
attributes in to a SqlServer StateServer? In other words, I would prefer not having to decorate these objects with the Serializable
attribute as I will also have to implement IXmlSerizable on all of these objects because they do not have empty contstructors, and non-public setters for properties.
views:
27answers:
1
+1
A:
There's no absolutely easy-peasy way to do this, no, unfortunately.
But: the ASP.NET session state mechanism is extensible, so you could imagine writing your own ASP.NET session state provider which basically uses the DataContractSerializer, and stores the serialized objects into SQL Server (or any other store, for that matter).
Check out MSDN Session-State Modes and Implementing a Session-State Store Provider.
Not a simple little switch to flick - but it would definitely be doable.
Or just decorate your objects with [Serializable]
and be done with it...
marc_s
2010-03-13 10:40:58