//1.
var userIdList = await _dbContext.Users.Where(m => m.TaskId == TaskId).Select(m => m.Id).ToListAsync();
var boardList = await _dbContext.BoardTabs.Where(m => userIdList.Contains(m.UserId) &&m.State==true).OrderByDescending(m=>m.CreateDate).Skip(page-1).Take(limit).ToListAsync();
//2.
var wholeRecord = _dbContext.Users
.Select(m => new { m.Id, m.TaskId, m.UserName, m.UsualScore })
.Where(m => m.TaskId == TaskId)
.Join(_dbContext.Tasks.Select(m => new { m.CaseId, m.TaskName, m.Id }), a => a.TaskId, g => g.Id, (a, g) => new { a.Id, a.UserName, a.UsualScore, g.TaskName, g.CaseId, a.TaskId })
.ToList(); //获取任务下所有学生以及班级信息
EF两表联查2种形式
最新推荐文章于 2024-04-30 21:37:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)