对象与实体框架表连接

时间:2013-02-18 04:19:50

标签: c# .net linq entity-framework

我有一个c#class

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;`

异常消息是:

  

无法处理类型'匿名类型,因为它没有已知的映射到值层

1 个答案:

答案 0 :(得分:0)

当前状态为空时,如何从lstVendorLocation获取商品?

你的意思是这样吗?

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