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

Where clause with compare - .NET Tutorial

From the course: .NET Essentials: LINQ for XML

Start my 1-month free trial

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