我在ASP.NET MVC项目中使用EF 4.4和SQL服务器,我的下面的查询冻结每次运行。
PSSAL
有426.000行,PU_CustProduct
有1600行
对查询有什么想法或提议吗?
var model = (from p in dbCont.PU_CustProduct
where !(from pt in dbCont.PSSAL
where pt.PSSAL_DATE > d1
&& pt.PSSAL_PSPRP_ID == p.CustProductID
select pt.PSSAL_PSPRP_ID).Contains(p.CustProductID)
&& p.IsActive == true
&& (!p.IsSleepMode == true)
&& p.ProductType == intId
&& p.CustomerID != null
&& p.IsSychSuspend != true
select new WarningViewModel
{
PrpName = p.LicenceName,
CrmID = p.CustomerID.ToString(),
PsprpId = p.CustProductID.ToString(),
}).Distinct().OrderBy(o => o.PrpName).ToList();