2013-02-18 194 views
0

我有一個C#類對象與實體框架表連接

public class VendorLocation 
{ 
    public string VendorCode { get; set; } 
    public string Location { get; set; } 
} 

和列表

var lstVendorLocation = new List<VendorLocation>(); 

下面的LINQ查詢被編譯並在運行時拋出異常:

var query = from s in DB.Sales 
      where lstVendorLocation.Any(vendorLoc => s.VendorCode.Equals(lstVendorLoc.VendorCode) && s.Location.Equals(lstVendorLoc.Location)) 
      select s;` 

例外信息是:

無法處理類型爲「匿名類型,因爲它沒有已知的映射值層

+0

爲什麼你在標題中放置標籤C#並且沒有在標籤框中? – abatishchev 2013-02-18 04:22:55

+0

'lstVendorLocation'的來源是什麼?如果可能的話,你應該嘗試使用它作爲原始的'IQueryable'。 – 2013-02-18 08:47:06

回答

0

你怎麼可以從lstVendorLocation得到一個項目時的當前狀態是空的?

你是不是這個意思?

var query = from s in DB.Sales 
           where ... 
           select new VendorLocation 
      { 
       .... 
      };`