【发布时间】:2022-09-12 18:33:42
【问题描述】:
我想使用 ReadOnlyAppService 的强大功能向我的 Angular 前端公开一个简单对象 (NetworkDevice)。所以我写了一个简单的应用服务:
public class NetworkDeviceAppService: ReadOnlyAppService<NetworkDevice, NetworkDeviceDto, Guid>, INetworkDeviceAppService
{
public NetworkDeviceAppService(IReadOnlyRepository<NetworkDevice, Guid> repository) : base(repository)
{
}
}
在 Angular 客户端中,我被迫发送PagedAndSortedResultRequestDto 以获取NetworkDevices:
private getNetworkDevices() {
let request = new PagedAndSortedResultRequestDto();
this.networkDeviceService
.getList(request)
.subscribe(res => {
this.networkDevices = res.items;
})
}
但我不想指定MaxCount,因为我想要所有对象,而不需要分页。
我怎样才能以干净的方式实现它。
我想到的不干净的解决方案:
- 以
maxResultCount发送 2'000'000 - 在我的
NetworkDeviceAppService中添加一个方法public async Task<IListResult<NetworkDeviceDto>> GetAllAsync() - 在客户端循环请求数据
有没有 PagedAndSortedResultRequestDto 的 ReadOnlyAppService 等价物?
【问题讨论】:
-
添加方法是要走的路。
-
我觉得它不干净,因为我在 Swagger 中有冲突:
Conflicting method/path combination "GET api/app/network-device" for actions。所以我需要添加一些代码来解决它。 -
以不同的方式命名,例如
GetAllsAsync。
标签: angular abp data-paging