1
Sirs,
I would like to view all queries that are generated when I use Lazy loading. When debugging view only the main.
In the Training controller this way:
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());
}
The view is 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 see only the query related to the Training, I can’t see the query related to the department, as I see?
in debug:
{SELECT
[Extent1].[TreinamentoID] AS [TreinamentoID],
[Extent1].[DepartamentoID] AS [DepartamentoID],
[Extent1].[NomeTreinamento] AS [NomeTreinamento],
[Extent1].[Creditos] AS [Creditos]
FROM [dbo].[Treinamento] AS [Extent1]}
Tower, next time, give a formatted in your code. =)
– Rubico
Rubico, ok. It was bad.rs
– Torres