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

View the generated SQL - .NET Tutorial

From the course: .NET Essentials: LINQ for Databases

Start my 1-month free trial

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