Solution:NIIT/GNIIT Sonugiri0032@gmail.com

Monday, February 01, 2016

See the SQL Generated by LINQ

See the SQL Generated by LINQ

When using LINQ to SQL, it can be very useful to see the SQL commands that are generated by your LINQ expressions. Sometimes the results are surprising and you might be able toimprove performance by tweaking the LINQ.All you have to do is set the Log property of the DataContext object. ...
When using LINQ to SQL, it can be very useful to see the SQL commands that are generated by your LINQ expressions. Sometimes the results are surprising and you might be able to improve performance by tweaking the LINQ.

All you have to do is set the Log property of the DataContext object. For example.
MyDataContext.Log = Console.Out;

This will cause the SQL commands generated by MyDataContext to appear in the outputwindow in the debugger. You probably shouldn't leave this in your code without at least wrapping a #if DEBUGaround it.
Share:

0 comments:

GNIITSOLUTION GNIIT SOLUTION. Powered by Blogger.

Translate

Blog Archive

Unordered List