From the course: LINQPad Essential Training
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Configure an XML file as a data source - LINQ Tutorial
From the course: LINQPad Essential Training
Configure an XML file as a data source
- Another SQL source is XML data. We can work with any valid XML string as the source. For my example, I'm working with the content of this XML file, this RobotName.xml. This is in the assets folder for the course so you can find it by going to open, go to assets, show all files, it's this file here. Let's take a look at the contents of this file. It starts with one root node called Robots, and then there are 12 of these children elements robot, and then there are some nested elements, robot name and weight, their child elements of robot, and there's also an attribute for each robot team-name. How do you load this into a SQL. That's what we have over here. So the first thing we need to do is load the XML into a query able type. For this example, I'm using this XElement type, which represents an XML element. So the top part of this code is creating the path to load the file. So on line three, I'm using…
Contents
-
-
-
-
-
-
(Locked)
What sources are valid for LINQ to Objects1m 21s
-
(Locked)
Basic LINQ query operators2m 3s
-
(Locked)
Write LINQ query expressions1m 49s
-
(Locked)
Connect to a database2m 9s
-
(Locked)
Query the database with SQL1m 37s
-
Use the DataContext1m 47s
-
(Locked)
Query the database with a LINQ expression2m 34s
-
(Locked)
Configure an XML file as a data source2m 35s
-
(Locked)
Query the XML file1m 8s
-
(Locked)
Filter by attributes54s
-
(Locked)
-
-
-
-
-
-