Sirs,
I would like to view all the queries that are generated when I use lazy loading. When debugging only the main view.
In the Training controller it looks like this:
public class TreinamentosController : Controller
{
private DbContext db = new DbContext();
public ActionResult Index()
{
db.Configuration.LazyLoadingEnabled = true;
IList<Treinamento> treinamentos = b.Treinamentos.ToList<Treinamento>();
//var treinamentos = db.Treinamentos.Include(t =>t.Departamentos);
return View(treinamentos.ToList());
}
In the view like this:
<table class="table">
<tr>
<th>@Html.DisplayNameFor(model => model.Departamentos.NomeDepartamento)</th>
<th>@Html.DisplayNameFor(model => model.NomeTreinamento)</th>
<th>@Html.DisplayNameFor(model => model.Creditos)</th>
<th></th>
</tr>
@foreach(var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Departamentos.NomeDepartamento)</td>
<td>@Html.DisplayFor(modelItem => item.NomeTreinamento)</td>
<td>@Html.DisplayFor(modelItem => item.Creditos)</td>
<td>
@Html.ActionLink("Editar", "Editar", new { id = item.TreinamentoID}) |
@Html.ActionLink("Detalhes", "Detalhes", new { id = item.TreinamentoID }) |
@Html.ActionLink("Excluir", "Excluir", new { id = item.TreinamentoID })
</td>
</tr>
}
</table>
When debugging I only see the query related to Training, I can not see the query for the department, how do I visualize it?
no debug:
{SELECT
[Extent1].[TreinamentoID] AS [TreinamentoID],
[Extent1].[DepartamentoID] AS [DepartamentoID],
[Extent1].[NomeTreinamento] AS [NomeTreinamento],
[Extent1].[Creditos] AS [Creditos]
FROM [dbo].[Treinamento] AS [Extent1]}