From the course: Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Solution: Filter results for invalid values
From the course: Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup
Solution: Filter results for invalid values
(upbeat music) - [Instructor] I hope you enjoyed working on this challenge. Here is how I solved the problem. First of all, let's look at my answers. So I found two elements that match my criteria. One is this color named Indigo, which has an invalid character, the letter H in the Hex. The second one is this color Mint.Cream, which has this period in the middle of the word. So the way I wrote this query is I started off by getting the webColors. And then I am making a call to this method called IsValidHex. So I wrote a variable here called isValid and I'm getting the Hex elements value, and then I'm passing that in to this method. We'll talk about the code here in a minute. Then I write a where clause where I say check for the color-name value contains a period, or this variable isValid == false. And then I orderby isValid and then I select out the results. This is one of the interesting parts of this query is how do you solve this IsValidHex. And the way I did it is by using…
Contents
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
(Locked)
Use Query syntax to work with elements4m 59s
-
(Locked)
Query element values in XML1m 10s
-
(Locked)
Query attributes in XML1m 56s
-
(Locked)
Project data into an anonymous type4m 10s
-
(Locked)
Filter by attribute value with Where1m 52s
-
(Locked)
Use Where to compare values2m 10s
-
(Locked)
Perform aggregate queries in XML1m 26s
-
(Locked)
Sort query results with OrderBy3m 29s
-
(Locked)
Find empty elements and blank values4m 51s
-
(Locked)
Group XML data with GroupBy3m 48s
-
(Locked)
Challenge: Create a custom string output1m 50s
-
(Locked)
Solution: Create a custom string output1m 19s
-
(Locked)
Challenge: Filter elements with no content52s
-
(Locked)
Solution: Filter elements with no content51s
-
(Locked)
Challenge: Filter results for invalid values1m 28s
-
(Locked)
Solution: Filter results for invalid values1m 54s
-
(Locked)
-
-