On a related note, my development team is relying on the ReadXML and WriteXML methods to create import and export functions.
Using the import function on the same database from which the export was performed works, apparently because the exported data matches, and the database is updated.
We are having problems, however, on trying to import the data in another replica of the database where the exported data does not already exist (we are assuming that the data gets inserted into the database).
For the import, we are essentially reading in the XML nodes and feeding them to new instances of the entities. We then invoke the Save() method of the entity to insert the data into the database.
Here is a function (with error checking removed for the sake of simplicity) to import records for a table InspectionHeader:
private void ImportRecordedInspectionHeaders(XmlNode xmlNode)
{
foreach (XmlNode node in xmlNode.ChildNodes)
{
InspectionHeaderEntity entity = new InspectionHeaderEntity();
entity.ReadXml(node);
entity.Save();
}
}
The entity appears to be be populated correctly, but the Save() function fails.
Is there something wrong with the logic?
Regards