【发布时间】:2021-01-13 22:16:18
【问题描述】:
User user = await _context.users
.Include(u => u.orders.Where(o => o.Date > startDate && o.Date < enddate))
.Where(u => u.UserID == _auth.User.UserID)
.FirstOrDefaultAsync();
所以我在用户和订单表之间有一对多的关系,其中用户模型有一个列表订单。但是我收到一个 500 服务器错误和“在 Include 中使用的 Lambda 表达式无效”
【问题讨论】:
-
Include用于急切加载所有相关数据,您不能使用任何类型的 LINQ 查询。如果需要过滤数据,需要在第二次查询中获取
标签: asp.net entity-framework .net-core