How to go from LINQ to SQL/Entities to XML/XSD?

Can anyone advise if there is a way to run a LINQ to SQL/Entities query and then convert the results into an XML document (e.g. XElement) without having to do the projection manually in code?

In other words, I don't want to have to manually iterate over the LINQ to SQL/Entities result and create XElement objects. I would rather be able to refer to some predefined database-entity-to-XML-schema mapping and have that do the work for me.

I've considered whether adding the System.Xml.Serialization attributes to the entity classes generated by the LINQ designers would work, but these might be lost every time the classes had to be regenerated.

So to cut to the chase, what is the quickest and/or least code-intensive way to go from database to an XML document in the schema of my choosing?

Thanks in advance for all replies.

[859 byte] By [DellaG] at [2008-1-5]

Visual Studio Orcas

Site Classified