CrudServiceBase add order by id and skip/take

This commit is contained in:
Фролов 2021-09-29 09:57:11 +05:00
parent c2c9bad200
commit c45b5728df

View File

@ -43,6 +43,14 @@ namespace AsbCloudInfrastructure.Services
if (skip >= count) if (skip >= count)
return container; return container;
query = query
.OrderBy(e => e.Id);
if (skip > 0)
query = query.Skip(skip);
query = query.Take(take);
var entities = await query var entities = await query
.ToListAsync(token) .ToListAsync(token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -58,6 +66,7 @@ namespace AsbCloudInfrastructure.Services
{ {
var query = GetQueryWithIncludes(); var query = GetQueryWithIncludes();
var entities = await query var entities = await query
.OrderBy(e => e.Id)
.ToListAsync(token).ConfigureAwait(false); .ToListAsync(token).ConfigureAwait(false);
var dto = entities.Select(entity => Convert(entity)); var dto = entities.Select(entity => Convert(entity));
return dto; return dto;