How can i look at generated sql query by LINQ? I tried LINQPad but as i understood i have to write LINQ statements into LINQPad.
Any ways without SQL Profiler?
I use it here:
public IEnumerable<PeopleTalesCategory> GetAllCategories()
{
return _dataContext.PeopleTalesCategories.OrderBy(c => c.PositionInMenu).ThenBy(c => c.NameAn);
}
If you are using Linq To Sql you can use a
StringWriterto get the Sql generated by the Linq To Sql. Here is an example that setup to theDataContextthe Log and execute a simple query to finally show insqlLinqToSql.Textthe SQL.If you are using Linq To Entity, it’s different. You need to call from the ObjectQuery the
ToTraceString():