how to see generated sql from a linq query
This popped up on Google, it's an 8-part tutorial. I think it will keep you busy for a few hours, it seems quite detailed to me.
1: http://weblogs.asp.net/scottgu/archive/2007/05/19/using-linq-to-sql-part-1.aspx
2: http://weblogs.asp.net/scottgu/archive/2007/05/29/linq-to-sql-part-2-defining-our-data-model-classes.aspx
3: http://weblogs.asp.net/scottgu/archive/2007/06/29/linq-to-sql-part-3-querying-our-database.aspx
4: http://weblogs.asp.net/scottgu/archive/2007/07/11/linq-to-sql-part-4-updating-our-database.aspx
5: http://weblogs.asp.net/scottgu/archive/2007/07/16/linq-to-sql-part-5-binding-ui-using-the-asp-linqdatasource-control.aspx
6: http://weblogs.asp.net/scottgu/archive/2007/08/16/linq-to-sql-part-6-retrieving-data-using-stored-procedures.aspx
7: http://weblogs.asp.net/scottgu/archive/2007/08/23/linq-to-sql-part-7-updating-our-database-using-stored-procedures.aspx
8: http://weblogs.asp.net/scottgu/archive/2007/08/27/linq-to-sql-part-8-executing-custom-sql-expressions.aspx
Good luck.
With Linq2Sql
dc.GetCommand(query).CommandText
see http://msdn.microsoft.com/en-us/library/system.data.linq.datacontext.getcommand.aspx for more info.
But I usually use LinqPad
There are 3 ways do that.
1.You can use LINQPad.It's Free http://www.linqpad.net/
2.You can use SQL Server Profiler inside the Sql Server (Tools --> SQL Server Profiler)
3.You can use Visual Studio Debugger for Generate T-Sql.(with any visual studio version)
Use SQL Profiler
if you are using SQL Server as your database.