如何在 linq toEntity 中进行选择以从列表中选择带有键的行?像这样的东西:
var orderKeys = new int[] { 1, 12, 306, 284, 50047};
var orders = (from order in context.Orders
where (order.Key in orderKeys)
select order).ToList();
Assert.AreEqual(orderKeys.Count, orders.Count);
我尝试使用Contains一些答案中提到的方法,但它不起作用并抛出此异常:
LINQ to Entities 无法识别“Boolean Contains[Int32](System.Collections.Generic.IEnumerable`1[System.Int32], Int32)”方法,并且此方法无法转换为存储表达式。
Try this:
var orderKeys = new int[] { 1, 12, 306, 284, 50047};
var orders = (from order in context.Orders
where orderKeys.Contains(order.Key);
select order).ToList();
Assert.AreEqual(orderKeys.Count, orders.Count);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)