I´m building the BL of an an app that will use linq to xml as dataaccess. I have succesfully done it for an editableroot and wrote unit tests for all methods.
Now I´m trying to figure out what should I pass, or the general concept for using FieldManager.UpdateChildren in the editableroot with an editablechildlist of editablechildlistitems in a linq to xml file storage scenario.
I googled: XElement FieldManager.UpdateChildren and the search yielded no results, so apparently is not something that has been widely done before.
My idea is that the root will persist itself, and throgh the FieldManager.UpdateChildren it will go to the children and the children collection should persist and do all the stuff.
I have done this before using linq to entities and it was simple, but this other scenario is quite different.
Any ideas, help or suggestions will be very welcomed!
Thank you and regards!
I would think that the parent would pass the XElement into which the child object will write its data.
That's pretty analogous to what you'd do with EF - pass the context in a state so the child can just write its data into the context.
The whole idea is that the child shouldn't know (or care) about the higher level structure of the XML - it should only care about writing its data into the XElement it was provided.
Thank you for your prompt answer.
I thought of that, but the idea is that each child will save its information to its own file.
So basically the root would save to something like: rootObj_rootGuid.xml
And the childs to rootObj_rootGuid_childObj_childGuid.xml files.
I´d like this way (and my boss even more), so rootObj_rootGuid.xml would have a collection of nodes pointing to the files it contains.
Is this right or you think that the whole approach doesn´t make sense?
And if it´s not that bad, how would you do it for achieving that objective?
I have not thought through an approach like that, sorry.
The key is to ensure that no object knows more than is absolutely necessary. Parent and child objects should know as little about each other as possible.
So it still seems reasonable to me that the parent would provide the child with an XElement into which the child would write the file name(s) it uses to store its data.
Thank you, I´ll try that.
Copyright (c) Marimer LLC