public static OrderDto Bulid(this OrderDto data, XprepayDbContext db) { data.OrderDetails = db.OrderDetails.Where(c => c.OrderId == data.Id).ToDtos().ToList(); return(data); }
public static PageResult <UserRoleDto> Build(this PageResult <UserRoleDto> result, XprepayDbContext db) { if (result.Value.Count == 0) { return(result); } var ids = result.Value.Select(x => x.UserId).ToArray(); var query = from a in db.UserRoleRLs where ids.Contains(a.UserId) select new { a.UserId, a.Role.Name }; var items = query.Distinct().ToList(); foreach (var dto in result.Value) { dto.Roles = items.Where(x => x.UserId == dto.UserId).Select(x => x.Name).OrderBy(x => x).ToArray(); } return(result); }