我在这里问了非常相似的问题
Entity framework - select by multiple conditions in same column - referenced table
现在关系是多对多。 所以我有 3 个表:order、items 和 orderItem(items 是一个 Junction 表) 再次......我想选择至少有一个价格为 100 的 orderItem 和至少有一个价格为 200 的 orderItem 的所有订单
我真的不知道如何为那个场景编辑它。
var orders = from o in kontextdbs.orders
select o;
foreach(int value in values)
{
int tmpValue = value;
orders = orders.Where(x => kontextdbs.order_item.Where(oi => x.id == oi.order_id)
}
最佳答案
修改后的版本
foreach(int value in values)
{
int tmpValue = value;
orders = orders.Where(x => (from oi in kontextdbs.order_item
join i in kontextdbs.items on oi.item_id equals i.id
where x.id == oi.order_id
select i).Any(y => y.price == tmpValue));
}
关于c# - Entity Framework - 按同一列中的多个条件选择 - 多对多,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10261674/