Hi,
Maybe I'm just spoiled by SQL, but is there some cool LINQ way to insert a new record into an "XML table" and have the indexed ID update automatically (or at least semi-automatically)?
Here's what I mean by "XML table":
<myElements>
<myElement>
<id>1</id>
<value>blah</value>
</myElement>
<myElement>
<id>3</id>
<value>blah</value>
</myElement>
<myElement>
<id>4</id>
<value>blah</value>
</myElement>
<myElement>
<id>8</id>
<value>blah</value>
</myElement>
<myElement>
<id>9</id>
<value>blah</value>
</myElement>
</myElements>
In this case, the table is "myElements" and the records are the "myElement" elements (i.e., the children of myElements).
The "id" element is defined as a key in the schema, so it acts more or less as a "primary key", just like it would in SQL.
So, my question is, how do I insert a new "myElement" where the "value" element is "whatever" and the "id" element is automatically set to the next available id (in this example, it would be max(id) + 1 = 10).
I have my XML database stored in an XDocument, so I'd like a solution that uses LINQ and/or methods of XElement.
Thanks!