0

I am currently using the following linq query

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();

but its really consuming time , like up to 30 plus seconds Is there an alternate way to trim on the execution time?

Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
MR K
  • 113
  • 1
  • 1
  • 12
  • possible duplicate of [Why is Entity Framework taking 30 seconds to load records when the generated query only takes 1/2 of a second?](http://stackoverflow.com/questions/686554/why-is-entity-framework-taking-30-seconds-to-load-records-when-the-generated-que) – chridam Oct 08 '14 at 07:45
  • You are bringing the data to the machine executing the code using the include. Make the query without include so that it is executed by dbms. – Adil Oct 08 '14 at 07:47
  • 4
    It's most likely due to all the `Include` calls - you should consider creating a view with all the relevant data and query that instead. – James Oct 08 '14 at 07:48

0 Answers0