// Display the document and save to disk.
Console.WriteLine(inventoryDoc);
inventoryDoc.Save("SimpleInventory.xml");
}
Figure 24-11 shows the SimpleInventory.xml file opened within Visual Studio 2008.
As you can see, the XElement and XDocument types each define a constructor that takes an
XName as the first parameter and a parameter array of objects as the second. The XName type is
used in LINQ to SQL to represent (obviously) the name of the item you are creating, while the
parameter array of objects can consist of any number of additional LINQ to XML types (XComment,
XProcessingInstruction, XElement, XAttribute, etc.), as well as simple strings (for element content)
or an object implementing IEnumerable.
C H A P T E R 2 4
■
P R O G R A M M I N G W I T H T H E L I N Q A P I S
860
8849CH24.qxd 10/19/07 10:11 AM Page 860
Figure 24-11.
The persisted XML document
Do'stlaringiz bilan baham: |