TotalCarbohydrates),
new XElement("TotalFat", itms.TotalFat),
new XElement("Cholesterol", itms.Cholesterol)
)
);
IcecreamsasXML.Save(@"c:\demo\Icecreams.xml");
XElement is an object of LINQ to XML, which is the main object to create an XML
file. The previous query is a mix of LINQ to XML and LINQ to SQL to fetch records
and present it in XML format. The XElement has the direct method to save its value
as XML file. The XElement takes care of creating the XML tree while the LINQ to
SQL query takes care of fetching records for the XML tree. The final output of the
above XML file will be as follows:
Chapter 4
[ 107 ]
Chocolate Fudge Icecream
4oz Scoop (113 grams)
4g
35g
15g
50mg
Vanilla Icecream
4oz Scoop (113 grams)
4g
26g
16g
65mg
Black Walnut Icecream
4oz Scoop (113 grams)
6g
25g
19g
50mg
Cotton Candy Icecream
4oz Scoop (113 grams)
4g
32g
12g
45mg
Joins
When we say joins, the first thing we think about is the foreign key relationship
between the database tables, which is very useful when we join the tables using
queries.
Pages:
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183