Search code examples
c#datacontractserializeropenaccess

DataContractSerializer skip OpenAccess Version's value


I'm using OpenAccess disconnected model. When I try to deserialize an object with DataConractSerializer, the Version property of this object is 0 - but only in the xml. If I debug the code and watch the value - it's 1 (or 2,3...)

If I say before the serialization "int temp = object.Version" the seriazlier can save the value.

There is a lazy issue, I'm sure. How can I force to read/save this value without explicit calls?

Code snippets: http://www.telerik.com/community/forums/orm/general-discussions/objectnetworkattacher-vs-datacontractserializer.aspx#775451


Solution

  • you should call the .Retrieve() method on your object which will load all the lazy-loaded fields and you will have all the data required for serialization. Hope that helps.