我有一个返回我 ID 的表达式:
var UserNotificationIds = _notificationBidderRepos.All(u => u.BidderId == BidderId).Select(n =>n.BidderId);
另一个结构有通知,要求过滤在 UserNotificationIds
中提供 Id 的通知
var AllNotifications = _notificationRepos.All(n => n.ExpiresAt > DateTime.UtcNow).ToList();
我正在尝试使用以下代码来查询所有通知,但没有了解如何在我的表达式中实现“where in”。
请帮忙
最佳答案
如果是根据 1 个 id 选择
selectAll.where(x => x.id == varId)
如果您传入多个 id,则需要使用 .Contains()。
selectAll.where(x => idList.contains(x.id))
关于c# - 在 Lambda 中实现 "where in"子句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21009101/