var data = _dbContext.Users.Join(_dbContext.Roles, u => u.RoleId, r => r.Id, (u, r) => new {u, r})
.Where(t => t.u.UserName == username && t.u.PassWord == password)
.Where(t => t.u.UserSite.All(x => x.UserId == t.u.Id))
.Where(t => t.r.RoleMenus.All(x => x.RoleId == t.r.Id))
.Select(t => new UserDto()
{
Id = t.u.Id,
UserName = t.u.UserName,
PassWord = t.u.PassWord,
RealName = t.u.RealName,
Phone = t.u.Phone,
RoleId = t.u.RoleId,
RoleName = t.r.RoleName,
LastIp = t.u.LastIp,
LastTime = t.u.LastTime,
Menus = t.r.RoleMenus.Select(x => (int) x.MenuId).ToList(),
Sites = t.u.UserSite.Select(x => x.SiteId).ToList()
});
先死记个套路