So what I'm doing is using an xml document to determine the order in which certain SQL scripts need to be ran by a database update.
The XML follows this format
<ScriptRules>
<Database databaseName = “string”>
<Folder folderPath = “string” executeAllFiles = boolean>
<file order=”first or last”>“Filename”</file>
</Folder>
</Database>
</ScriptRules>
So the class that executes all of the sql files on the database looks at this at changes it's connection and executes files from folders depending on what the config file has told it to do.
Now my question is this:
Let's say that I have a Document that has 4 Database nodes, and each of them have n number of Folder nodes inside with an assortment of file nodes inside of that.
Is it logical of me to assume that if inside of a For Each loop over the Database nodes that I have retrieved into a XElement using database.Elements("Database") that they will be pulled in the order that they appear in the xml file? (same for the file nodes)
As far as I have been able to tell this is the case but I just wanted to verify before I start using this on production databases.
Yes, Elements returns the elements in document order. From the docs, in the "return value":
An
IEnumerable<T>ofXElementcontaining the children of theXContainerthat have a matchingXName, in document order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With