Hi,
I'm using Xml.Serialization.XmlSerializer to serialize an entity graph (LLBLGen Pro runtime framework version 5.7.1). According to the documentation, the format used is the Compact25 format.
The use case for this is transferring an entity graph from one customer installation to another.
I just noticed that there is a problem when the entity types on both sides (serialize/deserialize) are different. In my case, the code that serializes the entities has one less property than the code that deserializes it. So basically, the customer who deserializes has an entity type that contains a property mapped to a table column "SomeNewField" that does not exist in the serialized entity description.
This leads to an exception when deserializing (There is an error in XML document (291, 8 ).) with the following InnerException:
Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.Collections.BitArray.Get(Int32 index)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2.Xml2Entity(XmlReader reader, Dictionary2 processedObjectIDs, List
1 nodeEntityReferences)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore1.ReadXml(XmlReader reader, XmlFormatAspect format)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore
1.ReadXmlExplicitImpl(XmlReader reader)
at SD.LLBLGen.Pro.ORMSupportClasses.EntityCore`1.System.Xml.Serialization.IXmlSerializable.ReadXml(XmlReader reader)
at System.Xml.Serialization.XmlSerializationReader.ReadSerializable(IXmlSerializable serializable, Boolean wrappedAny)
at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderList1.Read1_ArrayOfTImpExpEntity()
This happens on one of the many <_lps>
nodes. If we remove them from the XML document, everything works well.
I really don't care about all the state that's saved there. What I'm interested in is just to get the values of the generated properties across. If there is a property missing, I just expect it to be set to its default value. If there is a property too much, I just expect it to be ignored. Kind of what the basic .NET XmlSerializer does when serializing classes.
Is there a way to prevent these <_lps>
nodes from being generated? Or am I approaching the use case the wrong way?
Thanks,
andreas