I have a block of XML in a database which is easy enough to pull out using ASP.NET MVC, however I would like to access and modify the XML in an way more consistent with class instances. Is there a way to get the MVC (or any other model) to generate a data access (or p开发者_运维技巧erhaps Entity) class set from the DB-stored XML?
If the above is rather obtuse, the question could be summarised as; What method would you use to best access and modify XML stored in a database from an ASP.NET MVC application?
The method I went with in the end was simply to use LINQ2SQL to get the data from the SQL2005 DB and then pass the field value into XElement.Parse() to get an XML object I can easily work with. Manipulating the XML was the done using the information gained from helpful overflowers here:
How do I insert an element into XML using Linq?
How to add attributes to an element using LINQ, C#?
How to sort XML in LINQ C# by an attribute value? Also MVC
精彩评论