shapper <md*****@gmail.comwrote:
I am getting records from an SQL database using Linq.
I want to write these records in a XML file.
Each record would be a node in my XML file.
However, the attributes in the XML file have different names from the
columns of my object in the list.
How can I do this?
Assuming you've got a variable called "query" which does the relevant
SQL query, retrieving columns "Sql1", "Sql2" and you want to call them
"Xml1" and "Xml2":
XElement container = new XElement("container",
query.Select (sqlRow =new XElement("XmlNode",
new XElement("Xml1", sqlRow.Sql1),
new XElement("Xml2", sqlRow.Sql2))
);
--
Jon Skeet - <sk***@pobox.com>
Web site:
http://www.pobox.com/~skeet
Blog:
http://www.msmvps.com/jon.skeet
C# in Depth:
http://csharpindepth.com