This will help me understand LINQ a little better than everyone.
I tried using SQL Profiler, but I'm not sure how I can get it to show the actual SQL commands.
There is an excellent article on this subject on the ScottGu blog: http://weblogs.asp.net/scottgu/archive/2006/09/01/Understanding-LINQ-to-SQL-Query-Translations.aspx
There is a query visualizer that you can use by hovering over an object in the debugger.
Use the Log property for the DataContext object:
using (var dc = new DataContext()) { dc.Log = Console.Out; // Outputs the SQL statement to a System.IO.TextWriter object var customers = dc.Customers.Single(c => c.Customer_ID == 7); }
LINQ-SQL, - SQL Profiler. , - . , , .
LINQ-Entities, ObjectQuery<T>, .ToTraceString(), SQL, .
ObjectQuery<T>
.ToTraceString()
" " " " " ", TSQL , SQL: StmtStarting SQL: BatchStarting , , TextData.
, TextData SQL.
ScottGu .
You can also check out LinqPad ... you can create a standard Linq query and it will show you how it will look using expressions and standard Transact-Sql.
If you add your variable to your debug version in debug mode, and the value of your object will be an SQL query.