SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 289 | Next

Scott Klein

"Professional LINQ"

00


Not too bad. The next example utilizes the date attribute on the XML document to build the XML fragment.
Modify the code in your Visual Studio application as follows:
DateTime startDate;
DateTime endDate;
DateTime.TryParse("02/01/2007", out startDate);
DateTime.TryParse("02/28/2007", out endDate);
XElement xmlTree = new XElement("Sales",
from el in StreamSalesOrders(@"C:\Wrox\LINQ\Chapter 8\Orders.xml")
where (DateTime)el.Attribute("Date") >= startDate
&& (DateTime)el.Attribute("Date") <= endDate
select new XElement("Order",
new XElement("SalesPerson",
(string)el.Parent.Element("Name")),
new XElement(el.Element("Amount"))
)
);
This example uses the date attribute of each order to filter the information. Based on this criterion, the
following results are produced:


Scott
9.00


Steve
999.00


One more modification: the following example takes the order date attribute and adds it to the resulting
XML tree as an element.


Pages:
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6