Using the Log
LINQ to SQL sends SQL instructions each time it has to perform an operation on our demand. This is accomplished via its complex infrastructure that relies on the .NET Framework. By the way, as a developer you may be interested in understanding what really happens behind the scenes and in getting information about the real SQL instructions sent to SQL Server. Luckily you can use a SQL log that allows showing SQL instructions. You simply need to set the DataContext.Log property as follows, before taking actions you want to inspect:
northwind.Log = Console.Out
If you want to monitor everything happening, simply add the preceding code after the creation of the DataContext instance. If you apply this code before running the first example ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access