public async Task <string> QueryPagedAsync([FromQuery] CouponParam param) { var filter = param.SearchLambda <Coupon, CouponParam>(); var result = await _couponRepository.QueryPagedAsync(param.PageNum, param.PageSize, null, filter); var dtos = new List <CouponDto>(); foreach (var coupon in result.Items) { var productCategoryRelationList = await _couponProductCategoryRelationRepository.QueryAsync(c => c.CouponId == coupon.Id); var productRelationList = await _couponProductRelationRepository.QueryAsync(c => c.CouponId == coupon.Id); var dto = coupon.EntityMap <Coupon, CouponDto>(); dto.ProductCategoryRelationList = productCategoryRelationList.ToList(); dto.ProductRelationList = productRelationList.ToList(); dtos.Add(dto); } var pageData = new PagedDto <CouponDto> { Code = 200, Msg = "获取数据成功", Total = result.TotalResults, PageSize = param.PageSize, Data = dtos }; var json = pageData.ToString(); return(json); }