I'm currently working on a small web application using Visual Studio 2008 Express. I'm attempting to retrieve an XML document from a server using a client library and then save the document into a database column (using Linq). The database column has the data type specified as xml
. Unfortunately, I've been unsuccessful during my first few attempts.
Assuming that I've already got a reference to the data context object, here is the basics of what it is that I'm attempting to do:
// using a client library, requestthe XML document from the server
XmlDocument oXmlDoc = oClient.GetDataAsXML();
InformationLog oLog = new InformationLog();
oLog.InfoXML = oXmlDoc.InnerXml; // this is where the problem occurs
dbContext.InformationLogs.InsertOnSubmit(oLog);
dbContext.SubmitChanges();
Specifically, the error I get is:
Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.Linq.XElement'
I'm new to ASP.NET MVC and Linq, so I know that I'm missing something. In addition to the answer, I'm also curious as to why it's impossible to simply save the XML as-is without any additional processing.