2011-09-25 64 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

相關問題