2011-09-25 61 views
0

我试图运行下面的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 
       }); 
+0

请勿在EF名称中使用匈牙利符号。 – SLaks

回答

2

我认为,问题是,你不能在匿名类型的集合加入。

PricingId属性移动到后面的let子句并直接加入Customers

+0

的 '错误' 或者说错字是在这里: 在db.tblJobTasks加入T ON l.POID等于t.PurchaseOrderID 以dB为单位加入Ĵ** ** tblJobTasks上t.JobID等于j.JobID 该死智能感知!这应该是一个与'tblJobTasks'类似的不同表格。改变这个和查询的工作。我不能回答我自己的问题,因为我有不到100分! Steve – SteveB

相关问题