【发布时间】:2022-02-02 19:05:50
【问题描述】:
我在 .net 核心上实现了分层架构。 “核心、存储库、服务”包含模型和 dto。 在存储层中,我接收数据并将其发送到服务层。
但我想发送如下页数。我该怎么做?
此代码位于服务层。这就是我返回给用户的方式。我必须这样回去
ServiceRepository 我正在实现层的类
Task<CustomResponseDto<List<MaterialDemandDto>>> GetMaterialDemandList(int page, int pageSize);
public async Task<CustomResponseDto<List<MaterialDemandDto>>> GetMaterialDemandList(int page, int pageSize)
{
int totalCount;
var materialList = await _repository.GetMaterialDemandList(page, pageSize, out totalCount);
var materialDemandsListDto = _mapper.Map<List<MaterialDemandDto>>(materialList);
return CustomResponseDto<List<MaterialDemandDto>>.Success(200, materialDemandsListDto);
}
此代码位于存储库层中,这就是我将页数和所需数据发送到存储库层的方式。
但我想将此处的 totalCount 发送到服务层。所以我想发送到上面的代码
存储库 我正在实现层的类
Task<(List<MaterialDemand>, int)> GetMaterialDemandList(int page, int pageSize, out int totalCount);
public async Task<(List<MaterialDemand>, int)> GetMaterialDemandList(int page, int pageSize, out int totalCount)
{
IQueryable<MaterialDemand> query;
query = _context.MaterialDemands
.Include(c => c.MaterialDemandDetails)
.OrderByDescending(x => x.CreatedDate);
int totalCount2 = query.Count();
return (await query.Skip((pageSize * (page - 1))).Take(pageSize).ToListAsync(), totalCount2);
}
我收到此错误
异步方法不能有 ref、in 或 out 参数 DynamicManagemetn.Repository
【问题讨论】:
标签: asp.net-core asp.net-web-api