I have the following Action method:-
public ActionResult RackServer(int id) {
var servers = repository.AllFindRack_Servers(id).ToList();
var IT360IDs = servers.Select(a => a.Technology.IT360ID.Value).ToArray();
return PartialView("~/Views/Server/_nonPagedServerTable.cshtml", servers);
}
which calls the following repository method:-
public IQueryable<TMSServer> AllFindRack_Servers(int id)
{
return tms.TMSServers.Where(c => c.RackID == id)
.Include(a => a.OperatingSystem)
.Include(a3 => a3.TMSRack.DataCenter)
.Include(a14 => a14.TMSRack.Technology)
.Include(a6 => a6.TMSVirtualMachines)
.Include(a7 => a7.TechnologyStatu)
.Include(a8 => a8.TechnologyBackUpStatu)
.Include(a9 => a9.TechnologyRole)
.Include(a10 => a10.Technology.TechnologyIPs)
.Include(a11 => a11.TMSServer1.Technology)
.Include(a14=>a14.TMSServers1)
.Include(a12 => a12.TMSSwitches)
.Include(a13 => a13.TMSFirewalls);
}
but i have noted that in case i chnage the .Tolist() position within my action method to be as:-
public ActionResult RackServer(int id) {
var servers = repository.AllFindRack_Servers(id);
var IT360IDs = servers.Select(a => a.Technology.IT360ID.Value).Tolist().ToArray();
return PartialView("~/Views/Server/_nonPagedServerTable.cshtml", servers);
}
then two queries to the repository method will be done ? can anyone explain why having .Select & .Tolist() inside the same statement is causing two similar quires to be executed.?
Thanks