There are several ways to debug your Linq to sql
- Sql Server Profiler
But How about if you share your Sql Server with others such as staging DB ?
It will be nightmare. - DataContext Command
Console.WriteLine(ctx.GetCommand(prods).CommandText);
But How about if you don't want to write any debug code ? - LINQ to SQL Debug Visualizer
I think this is the best way to debug your LINQ to SQL.
You can use .NET Debugging ModeAnd Click small magnifying glass in the expression above, It will launch the LINQ to SQL debug visualizer to inspect the raw SQL that the ORM will execute based on that LINQ query:
Click "Execute" button, you can even test out the SQL query and see the raw returned results that will be returned from the database:
Installing SQL debug Visualizer :
- Download Linq to Sql Debug Visualizer http://www.scottgu.com/blogposts/linqquery/SqlServerQueryVisualizer.zip - (From Scott Gu Blog)
- Copy from \SqlServerQueryVisualizer\bin\Debug\SqlServerQueryVisualizer.dll
- Copy to C:\Program Files\Microsoft Visual Studio 9.0\Common7\Packages\Debugger\Visualizers
You may start debug your LINQ...
No comments:
Post a Comment