I have an Add and an Update function to update a listing in an xml database I'm working on. In the add function i do this:
new XElement(ImageUtilities.GetImageXElement(series.image)),
It basically takes an image object, does some background stuff (which works fine) and returns an XElement. This works flawlessly. The problem comes when I am trying to do an update. I'm essentially trying to do the following.
xseries.SetElementValue(ImageUtilities.GetImageXElement(series.image));
I've tried the following which obviously doesn't work, but I am thinking that some variation of it will work, it compiles, but it wont run. It gives the error: "System.ArgumentException: An XObject cannot be used as a value." I've googled it, and nothing seems to say, You update an element with an element by.
xseries.SetElementValue("image", ImageUtilities.GetImageXElement(series.image));
I am able to get it to work properly by doing:
xseries.Element("image").SetAttributeValue("guid", series.image.guid);
xseries.Element("image").SetAttributeValue("main", series.image.main);
xseries.Element("image").SetAttributeValue("height", series.image.height);
xseries.Element("image").SetAttributeValue("width", series.image.width);
xseries.Element("image").SetAttributeValue("order", series.image.order);
... and so on.
but if the image object changes I'll have to go back in and change everything I've done later. Any thoughts would be appreciated. Thanks!
 
No comments:
Post a Comment