Рефактор

This commit is contained in:
Olga Nemt 2023-02-02 15:58:07 +05:00
parent a4ff666b97
commit e81abc86e6

View File

@ -89,27 +89,12 @@ namespace AsbCloudInfrastructure.Services.SAUB
Count = query.Count()
};
var hasAllSortedFieldsInDBOType = false;
if (sortFields?.Any() == true)
{
hasAllSortedFieldsInDBOType = hasAllFieldsInType<TelemetryMessage>(sortFields);
if (hasAllSortedFieldsInDBOType)
{
query = query
.SortBy(request.SortFields)
.Skip(skip)
.Take(take);
query = query.SortBy(request.SortFields);
}
}
else
{
query = query
.Skip(skip)
.Take(take);
}
var messagesList = await query.AsNoTracking()
var messagesList = await query.Skip(skip)
.Take(take).AsNoTracking()
.ToListAsync(token).ConfigureAwait(false);
if (messagesList.Count == 0)
@ -150,14 +135,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
result.Items.Add(messageDto);
}
if (sortFields?.Any() == true && !hasAllSortedFieldsInDBOType)
{
result.Items = result.Items.AsQueryable()
.SortBy(request.SortFields)
.Skip(skip)
.Take(take)
.ToList();
}
return result;
}