From the course: .NET Essentials: LINQ for Databases
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
View the generated SQL - .NET Tutorial
From the course: .NET Essentials: LINQ for Databases
View the generated SQL
- [Instructor] Not only can you see the query provider information and the expression tree, you can also get the SQL that is generated and sent to the database. There's a couple of ways of doing that. I'll start by looking at the DB set. The DB set has a property called SQL and I can read that value and see the SQL that is created. So I select this line of code and execute the query. And this is what is sent to the database. It's a select statement, selecting these columns from this table. I can also call ToString to get the same data. Like this. Okay, now let's look at a query expression. Now I'm generating a query and I'll run the query here. This is going to be a DB query type. It doesn't have a .SQL property on it, but it does have ToString that works the same way. So we'll select these lines of code and run it. This shows you how to programmatically get this information. So if you want to write code to get this…
Contents
-
-
-
-
-
Explore the relevant LINQ types4m 24s
-
Understand the DbContext2m 38s
-
Queryable types: DbSet and DbQuery1m 30s
-
DbSet, the basis for EF collection models1m 57s
-
Save changes in DbSet3m 1s
-
DbQuery, the basis of LINQ queries for EF models1m 4s
-
Interfaces: IEnumerable and IQueryable1m 41s
-
View the Expression Tree1m 20s
-
View the generated SQL1m 25s
-
-
-
-