Debugging LINQ to Entities programs
In Visual Studio 2010, when debugging a LINQ to Entities program, we can use the traditional Watch or Autos windows to inspect a variable. For example, after the following line is executed, we can go to the Autos window to see the contents of the products
variable:
var products = from p in NWEntities.Products where p.CategoryID == 1 select p;
The Autos window should look like this:
We can also hover our mouse over the products variable, wait for the Quick Info pop-up window to appear, and then inspect it on the fly. The pop-up Quick Info window will appear as shown in the following image:
In either of the windows we can inspect the returned result of the variable, its properties, and even its children.
Note
This inspection may trigger a real query to the database. For example, if you try to open Results View, the database will be queried to get all of the products that meet the search criteria. This may have some side effects if...