Generating Documents from LINQ Queries
As far as that last point is concerned, assume we have an anonymous array of anonymous types
that represent a simple Car class. We could now create an array of these objects and build a LINQ
query that will select each name/value pair to dynamically build a new XElement:
static void CreateXmlDocFromArray()
{
// Create an anonymous array of anonymous types.
var data = new [] {
new { PetName = "Melvin", ID = 10 },
new { PetName = "Pat", ID = 11 },
new { PetName = "Danny", ID = 12 },
new { PetName = "Clunker", ID = 13 }
};
Do'stlaringiz bilan baham: |