Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/linq/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# LINQ join需要很多时间_C#_Linq_Join - Fatal编程技术网

C# LINQ join需要很多时间

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

我目前正在使用以下linq查询

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
调用造成的-您应该考虑创建一个包含所有相关数据的视图,然后进行查询。