我有以下 viewModel 类:-
public class RackJoin
{
public TMSRack Rack { get; set; }
public Resource Resource { get; set; }
public Technology Technology { get; set; }
public ComponentDefinition ComponentDefinition { get; set; }
public SDOrganization Site { get; set; }
public SDOrganization Customer { get; set; }
}
以及以下用于连接两个实体的未完成存储库模型方法:-
public IQueryable<TMSRack> AllFindRacks(string q)
{
List<RackJoin> rakjoin = new List<RackJoin>();
var result = from rack in tms.TMSRacks
.Include(rack => rack.DataCenter)
.Include(rack => rack.Zone)
.Include(rack => rack.TMSFirewalls)
.Include(rack => rack.TMsRouters)
.Include(rack => rack.TMSServers)
.Include(rack => rack.TMSStorageDevices)
.Include(rack => rack.TMSSwitches)
.Include(rack => rack.Technology)
join resource in entities.Resources
.Include(a => a.ComponentDefinition)
.Include(a => a.ResourceLocation.SiteDefinition.SDOrganization)
.Include(a => a.ResourceLocation.SiteDefinition.AccountDefinition.SDOrganization)
on rack.Technology.IT360ID equals resource.RESOURCEID
where (q == null || rack.Technology.Tag.ToUpper().StartsWith(q.ToUpper()))
select //not sure what i should write here;
第一个问题;但我不确定如何List<RackJoin>
在上述方法中根据连接结果填充。
第二个问题;我从以下操作方法调用上述方法:-
public ActionResult Index(string searchTerm = null, int page = 1)
{
var racks = repository.AllFindRacks(searchTerm).OrderBy(a => a.Technology.Tag).ToPagedList(page, 5);
if (Request.IsAjaxRequest())
{
return PartialView("_RackTable", racks);
}
return View(racks);
}
所以我能知道分页和连接是如何一起工作的吗?我的意思是 EF 会对满足 where 子句的所有记录进行连接,然后它会跳过并取走。以及跳过和采取将应用于哪些实体?