DCSIMG
LINQ To SQL - Get the SQL text query - Gilad Lavian's Blog

Gilad Lavian's Blog

In Development

LINQ To SQL - Get the SQL text query

Usually when we perform a LINQ Query on a SQL table, we don't see the actual query.
Assuming you have the AdventureWorks Database installed.
To see the query text, use the Log method: aw.Log = Console.Out
 
public List<Employee> GetEmployees()
{
    AdventureWorksDataContext aw = new AdventureWorksDataContext();

    var employees = from emps in aw.Employees 
                    select emps;

    aw.Log = Console.Out;

    return employees.ToList();
}

 

The result:

LINQ Actal Query

שלח תגובה

(שדה חובה)  

(שדה חובה)  

(אופציונלי)

(שדה חובה) 

Please add 5 and 1 and type the answer here:


Enter the numbers above: