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.
Challenge: Create a custom string output
From the course: Complete Guide to .NET LINQ: Querying Collections, Databases, and Markup
Challenge: Create a custom string output
(gentle music) - [Instructor] It is time for your first code challenge. In this optional activity, I pose a small coding problem and you have the opportunity to create your own solution. The goal of this challenge is to write a link query that projects data into a custom anonymous type. The XML data that you will work with is in a file called webcolorsa.xml. You can find that here in the data folder, there it is. The contents of this file, there's a root element called web colors. Then there are a number of children elements. Here's an example, so this color element has two attributes, color name and color family, and it has several elements, hex, red, green, and blue, and hue, saturation and lightness. Your task is to retrieve the color name and to retrieve these three values. Then you're going to project out that information from your query. So here's what my solution looks like. Not the code, but what the solution looks like. So I created a type that has a color name, property, and…
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)
-
-