I am getting a massive XML payload from my WCF service and I need to write it to the SQL database. I am using the latest version of .NET and Entity Framework 6.
“Okay, that's great,” you can say, “but what is the question?”
Well, XML is deserialized into C # objects (generated from paste-special), and they work just fine. However, when the load from the service does not contain a field, I get an empty exception link when I write an XML object to an EF object (This is a class method):
public ICollection<object> GetObjects() { List<object> objs = new List<object>(); foreach (var i in XmlObject.SubObj.SubObj.SubObj) { objs.Add(new MyEfObject() { Prop1 = XmlObject.SubObj.SubObj.SubObj.ObjProperty
So I have really inelegant code to check
if (!ReferenceEquals(XmlObject.SubObj.SubObj.SubObj.ObjProperty, null) {
This is usually normal, but the object is so large, and I want to avoid entering this 150+ times (and for all properties of the object).
There should be a more elegant way, no?
Ellis source share