Monday 15 April 2013

c# - Eager Loading Complex Query with Entity Framework 5 -


I am loading ServiceTrips for the scheduling calendar and wondering if Fastest way

This is the model that should be loaded (mapping table per concrete type)

  public class servicestrip: BaseInte {Public Icicle & Lt; Employee & gt; Crew Set; } Public iconging & lt; Service status & gt; Assignment {Receive; Set; Public Service Service Order: Public Entity Order Order Order (Receipt; Set;) Public Delivery Order Order (Receipt); Set;}} Public Class Service Order: OrderBase {} Public Class Delivery Order: Orderbiz {} Public Essential Class Orderbase: BaseIntext (Public Icatalog & lt; Service Assetment & gt; Assignment {Receive; Set;} Public Sales Sales {get; Set;}} Nick Class Sale: Benthente {Public Employee Manager {get} set;} Public Customer Customer {Received; Set;} Public IcLing  Service Operators {Receive; Set;} Public Icoding & Delivery; Delivery Order & gt; ; Delivery order [receive; set;}} Public class staff: BaseInty {} Public class customer: BasInty {} Public abstract class base entity {Public Entry ID (Receipt) T;} The public string name {get} set;}}   

I have originally tried such things and do not know where to start. < Pre> var tripsQuery = db.ServiceTrips. Where (x = & gt; x.startdate> = first day and x startdate & lt; = last day). (X = & gt; x.Crew). (X = & x; x.ServiceAssignments). (Include X = & gt; X.ServiceAssignments.Select (y = & gt; y.DeliveryOrder)). (X => x.ServiceAssignments.Select (y = & y; y.ServiceOrder)). (X = & gt; x.ServiceAssignments.Select (Y = & gt; y.DeliveryOrder.Sale)). (X = & gt; x.ServiceAssignments.Select (y = & y; service order ..Sale)). (X => x.ServiceAssignments.Select (y = & Gt; y.DeliveryOrder.Sale.Customer)). (X => x.ServiceAssignments.Select (y = & y; y.ServiceOrder.Sale.Customer)). (X => x.ServiceAssignments.Select (Y = & gt; y.DeliveryOrder.Sale.Manager)). (X => x.ServiceAssignments.Select (y = & gt; y.ServiceOrder.Sale.Manager));

The model is simple for this question, I'm dragging about 20 tables in production, it takes about 10-15 seconds to load. I tried to load asynchronously every day, but increased in total time to load from this.

In my opinion when you have been given some guidelines (some point here) For SQL Server, which I have assumed is independence, check the query execution scheme on QQ SQL - if it takes time to reproduce the entire EF code in SQL - for example - servicetrips, serviceAgements and Delivery order table

  • Inspect, due to the size of the data, network latency is interrupted and no query <

  • Architecture - To speed up such complex queries Any kind of caching can be used to store the proper data - perhaps in the case of your manager, crew name.

  • No comments:

    Post a Comment