我试图运行下面的linq语句。我收到以下错误消息:LINQ:LINQ中不支持指定的类型成员
指定的类型成员的客户ID“在LINQ是不支持的实体。仅支持初始化程序,实体成员和实体导航属性。
我通过代码加强,当我需要查询并尝试使用转换“ToList()”它发生。
任何想法?我将如何重写此查询,以便LINQ to Entities停止抱怨。
史蒂夫
var query = from l in db.QBPOLines
join t in db.tblJobTasks on l.POID equals t.PurchaseOrderID
join j in db.tblJobTasks on t.JobID equals j.JobID
join c in
(
from c in db.tblCustomers
select new
{
c.CustomerID,
PricingID = c.PricingID == null || c.PricingID == 0 ? 1 : c.PricingID
}
) on j.CustomerID equals c.CustomerID
join m in db.QBItemsPriceMaps on l.Item equals m.ItemName
join s in db.tblCustomerPricingSchemes on c.CustomerID equals s.CustomerID into g1
from s in g1.DefaultIfEmpty()
join p in db.tblPricingSchemes on l.LangPairs equals p.PSLangPairID into g2
from p in g2.DefaultIfEmpty()
where t.JobID == jobID
&& s.PSLangPairID == l.LangPairs
&& p.PSDescID == c.PricingID
select new
{
j.JobID,
l.Item,
l.LangPairs,
l.Qty,
Rate = s.PSLangPairID != null
? (m.CustomerPriceField == "PS_FZ50" ? s.PS_FZ50 :
m.CustomerPriceField == "PS_FZ75" ? s.PS_FZ75 :
m.CustomerPriceField == "PS_FZ85" ? s.PS_FZ85 :
m.CustomerPriceField == "PS_FZ95" ? s.PS_FZ95 : null)
: (m.CustomerPriceField == "PS_FZ50" ? p.PS_FZ50 :
m.CustomerPriceField == "PS_FZ75" ? p.PS_FZ75 :
m.CustomerPriceField == "PS_FZ85" ? p.PS_FZ85 :
m.CustomerPriceField == "PS_FZ95" ? p.PS_FZ95 : null)
};
List<tblJobManagementLineItem> list = query.ToList().ConvertAll(i => new tblJobManagementLineItem
{
JobID = i.JobID,
LineItemDescr = i.Item,
LanguagePairID = i.LangPairs,
SourceWordCount = (int)i.Qty,
QtyToInvoice = (int)i.Qty,
//item.JobInvoiceID <--- Implement later
Rate = i.Rate
});
请勿在EF名称中使用匈牙利符号。 – SLaks