我們是在把SQL /存儲過程LINQ到實體報表的過程。問題SQL轉換到LINQ到實體聲明
目前我將這個SQL:
declare @startDate DateTime
set @startDate = DATEADD(DD, -30, GETDATE())
select h.*
from History h (nolock)
inner join Quote q (nolock) on h.QuoteID = q.QuoteID
inner join Agency (nolock) a on q.AgencyID = a.AgencyID
inner join DC_PLT_EntityRoles er (nolock) on a.AgencyID = er.EntityID
inner join DC_PLT_Roles (nolock) r on er.RoleID = r.RoleID
where
q.Status = 'Inforce'
and q.LOB = 'Vacant'
and q.EffectiveDate > @startDate
and h.Deleted is null
and h.DeprecatedBy is null
and h.TransactionStatus = 'Committed'
and r.Name = 'Wholesaler'
這是LINQ到實體,我寫了:
var startDate = DateTime.Today.AddDays(-30);
var results = (from h in Histories
.Include("Quote")
.Include("Quote.Agency")
.Include("Quote.Agency.DC_PLT_Roles")
where h.Quote.Status == "Inforce" &&
h.Quote.LOB == "Vacant" &&
h.Quote.EffectiveDate > startDate &&
h.Deleted == null &&
h.DeprecatedBy == null &&
h.TransactionStatus == "Committed" &&
h.Quote.Agency.DC_PLT_Roles.All(r => r.Name == "Wholesaler")
select h).ToList();
的問題是SQL返回77行,我的LINQ返回無。
任何人有我如何才能正確地轉換任何想法?或者我錯過了什麼。
感謝您的幫助。
[R
這做到了。你搖滾!我誠實地試圖通過評論不同的線條來縮小我對問題的搜索範圍,我認爲我嘗試了這一點。然而,它讓我沒有在哪裏。再次感謝。 – Richard 2012-02-10 18:44:12