C# LINQ join需要很多时间
我目前正在使用以下linq查询C# LINQ join需要很多时间,c#,linq,join,C#,Linq,Join,我目前正在使用以下linq查询 lsttask = (from d in administrationEntities.Tasks .Include("Status") .Include("Priority") .Include("Batch") .Include("Batch.ShipmentGroup") .Include("Batch.ShipmentGroup.Shipment") .Include("Batch.ShipmentGroup.Shipment.TO
lsttask = (from d in administrationEntities.Tasks
.Include("Status")
.Include("Priority")
.Include("Batch")
.Include("Batch.ShipmentGroup")
.Include("Batch.ShipmentGroup.Shipment")
.Include("Batch.ShipmentGroup.Shipment.TOCShipmentManifests.TOCShipmentDetails.TOCShipmentProcesses")
.Include("Batch.ShipmentGroup.Shipment.Project")
.Include("TaskType")
where ((projectId == null ? true : d.Batch.ShipmentGroup.Shipment.Project.ProjectId == projectId)
&& ( statusId == null ? true : d.StatusId == statusId)
&& d.IsDeleted == false)
select d)
.ToList();
但这真的很耗时,比如30多秒
是否有其他方法来调整执行时间?可能重复您使用include将数据带到执行代码的机器。在不包含的情况下进行查询,以便由dbms执行。这很可能是由于所有的
include
调用造成的-您应该考虑创建一个包含所有相关数据的视图,然后进行查询。