改进Linq to Entities查询性能

时间:2014-03-02 23:56:03

标签: c# sql performance entity-framework linq-to-entities

我有以下查询,我希望在性能方面有所改进。

有人可以协助吗?

var a = (from u in db.MEMBER_SUBSCRIPTION 
         join s in db.MEMBER_SUBSCRIPTION_SCHEDULE on u.Id equals s.SubscriptionId 
         where (u.QueueTypeId == queueType.Id) && (u.Enabled) && 
         (u.MinWaitingTimeToNotifyInMin <= currentQueueTimeInMin) && 
         ((u.MonitorIndefinitely) || ((u.MonitorStartDate <= today) && 
         (u.MonitorEndDate >= today))) && (((s.DayOfWeek == (int)today.DayOfWeek) && 
         (s.MonitorBetweenTimes == false)) || ((s.DayOfWeek == (int)today.DayOfWeek) &&
         (s.MonitorBetweenTimes) && 
         (System.Data.Entity.DbFunctions.CreateTime(s.StartTime.Value.Hour, s.StartTime.Value.Minute, s.StartTime.Value.Second) <= today.TimeOfDay) &&
         (System.Data.Entity.DbFunctions.CreateTime(s.EndTime.Value.Hour, s.EndTime.Value.Minute, s.EndTime.Value.Second) >= today.TimeOfDay))) select u).ToList();

0 个答案:

没有答案