以下mysql查询的linq lambda表达式是什么
Select Count(*), Users.BusinessName From Offers
inner join Users on Users.UserId = Offers.UserId
inner join RoleUsers on RoleUsers.User_UserId = Users.UserId
inner join Roles on Roles.RoleId = RoleUsers.Role_RoleId
where Roles.RoleName = 'Seller'
group by Users.BusinessName
根据用户名称(用户是卖家的位置)计算要约数量和组数。
public static List<CountsByUser> NoOffersByUserType()
{
List<Offer> offers;
using (MainDb ctx = new MainDb())
{
var role = ctx.Roles.FirstOrDefault(r => r.RoleName == "Seller");
List<User> users = role.Users.ToList();
offers= ctx.OfertaPret.Any(u => u.User == users).ToList();
//here is the problem u.User ==users
}
List<CountsByUser> requests = offers.GroupBy(o => o.User.BusinessName)
.Select(nl => new CountsByUser
{
name = nl.Key,
number = nl.Count()
})
.ToList();
return requests;
}
答案 0 :(得分:0)
offers= ctx.OfertaPret.Include(u=>u.User)
.Where(u => u.User.Roles.Any(r => r.RoleName == "Seller")).ToList();