开发者

Serialization with Subsonic Generated Objects

开发者 https://www.devze.com 2023-01-10 03:37 出处:网络
Is there any reason why the class \'SubSonic.Repository.SubSonicR开发者_C百科epository\' in the SubSonic.Core assembly (3.0.0.3) is not marked as Serializable? Or know of a workaround to serialize a s

Is there any reason why the class 'SubSonic.Repository.SubSonicR开发者_C百科epository' in the SubSonic.Core assembly (3.0.0.3) is not marked as Serializable? Or know of a workaround to serialize a subsonic generated class.

I added a subsonic generated object into the viewstate and got an error saying the object wasn't marked as Serializable. So I created an extention (using a partial class) to my generated object which I thought would be enough but it's now complaining about the above class in the SubSonic Assembly needs marking as Serializable too.


When a class is not serializable (and other classes from the same namespace are) there usually is a good reason.

The repository probably contains (or manages) a connection to the Db, and a connection is not serializable, for good reasons. Because on deserialization, it would be complex (and possibly unsecure) to establish another connection. You couldn't get the same connection back anyway.

0

精彩评论

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