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.
Where clause with compare - .NET Tutorial
From the course: .NET Essentials: LINQ for XML
Where clause with compare
- So in this example, we're going to use a where clause that evaluates one of the element values. So I started off by using all of the card elements and then I'm using this technique with the let keyword where I can declare a variable that can be used within the body of the query expression. So I'm saying, let this variable bid equal and then I'm drilling down into the elements to find the bid price and then I want to do a where clause here. Remember that the data that is coming from the content of an element is typed as text. So since I want to compare that against a numeric value or this decimal value, I have to parse that into a decimal. So I'm saying where decimal dot parse bid dot value is greater than 12. Once I do that then I create this new type which has a card name and the bid price looks like this. So I have five items. Now I can also add formulas. So what I want to do is when I'm outputting my results I want…
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)
-
-