LINQ to Entities无法识别该方法

时间:2010-08-24 08:19:41

标签: linq linq-to-entities

LINQ to Entities无法识别方法'Boolean Contains(Int32)'方法,并且此方法无法转换为商店表达式。

    var warranty_yes = from i in devicesEntities.device
    where i.WarrantyDate >= DateTime.Now
    select i.Id;

    var warranty_yes_list = warranty_yes.ToList();

    var view_query = from i in devprim_by_status
    where warranty_yes_list.Contains(i.Id)
    select i;

这是解决这个问题的方法吗?

1 个答案:

答案 0 :(得分:3)

您可以在一个查询中执行此操作:

var view_query =
    from i in devprim_by_status 
    join d in deviceEntities.device on i.Id equals d.Id
    where d.WarrantyDate >= DateTime.Now
    select i;