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.

Query the database with a LINQ expression

Query the database with a LINQ expression - LINQ Tutorial

From the course: LINQPad Essential Training

Query the database with a LINQ expression

- [Instructor] Now, let's write a LINQ Query expression. So I'll switch to C# statements, open my connection, I'll declare a variable for the query, start the syntax from P in, and notice what happens when I press the space bar. Since I'm in the LINQ Query expression, LINQPad shows me a list of all of the classes that are in the data context, is a one-to-one mapping between these classes and the tables. And I want the Products class, and then I'll say select P, this becomes a pass through query, it'll show all rows and all columns. And now I need to dump the information, like this. Execute the query, and I get 77 rows and all the columns. Now this is wonderful, because I didn't have to create the connection, I opened the connection, the table is already populated with data, just like we saw in some of the early videos. I'm working with this query expression and LINQPad is doing all the work of getting the data…

Contents