From the course: .NET Essentials: LINQ for XML
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Select data into a new anonymous type - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Select data into a new anonymous type
- [Instructor] One of my favorite features in link to objects is the ability to take the result and project them into a type. It can be predefined type or often we use a on the fly type created in our query. That's called an anonymous type and that's what we're doing here. So we started off the same. I do my query expression and I'm going to query the elements. We'll skip over lines 11 and 12 for a minute. And then down here I select out the new type and I provide the three property values or the property names I should say for that type card name, bid price, and catalog price. And I can see the types over there. It's a string, string and string. And then from my query, I get information. So here I'm pulling information from the attributes. So I'm going to the card name attribute and I'm getting it's value that gets assigned to the card name. And then here, I'm using these variables that it declared within the body…
Contents
-
-
-
-
-
(Locked)
Use Query syntax to work with elements2m 46s
-
(Locked)
Attribute query1m 27s
-
(Locked)
Select data into a new anonymous type1m 47s
-
(Locked)
Where clause on attribute value1m 53s
-
(Locked)
Where clause with compare2m 11s
-
(Locked)
Aggregate queries2m 1s
-
(Locked)
Choose output order with OrderBy42s
-
(Locked)
Query for empty elements and blank values3m 21s
-
(Locked)
Group by3m 26s
-
(Locked)
Challenge: Create custom string output1m 46s
-
(Locked)
Solution: Create custom string output1m 14s
-
(Locked)
Challenge: Filter results to show elements with no content47s
-
(Locked)
Solution: Filter results to show elements with no content55s
-
(Locked)
Challenge: Filter results to show invalid values1m 39s
-
(Locked)
Solution: Filter results to show invalid values1m 53s
-
(Locked)
-
-