forked from ddrilling/AsbCloudServer
Рефактор
This commit is contained in:
parent
a4ff666b97
commit
e81abc86e6
@ -89,27 +89,12 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
Count = query.Count()
|
Count = query.Count()
|
||||||
};
|
};
|
||||||
|
|
||||||
var hasAllSortedFieldsInDBOType = false;
|
|
||||||
|
|
||||||
if (sortFields?.Any() == true)
|
if (sortFields?.Any() == true)
|
||||||
{
|
{
|
||||||
hasAllSortedFieldsInDBOType = hasAllFieldsInType<TelemetryMessage>(sortFields);
|
query = query.SortBy(request.SortFields);
|
||||||
if (hasAllSortedFieldsInDBOType)
|
|
||||||
{
|
|
||||||
query = query
|
|
||||||
.SortBy(request.SortFields)
|
|
||||||
.Skip(skip)
|
|
||||||
.Take(take);
|
|
||||||
}
|
}
|
||||||
}
|
var messagesList = await query.Skip(skip)
|
||||||
else
|
.Take(take).AsNoTracking()
|
||||||
{
|
|
||||||
query = query
|
|
||||||
.Skip(skip)
|
|
||||||
.Take(take);
|
|
||||||
}
|
|
||||||
|
|
||||||
var messagesList = await query.AsNoTracking()
|
|
||||||
.ToListAsync(token).ConfigureAwait(false);
|
.ToListAsync(token).ConfigureAwait(false);
|
||||||
|
|
||||||
if (messagesList.Count == 0)
|
if (messagesList.Count == 0)
|
||||||
@ -150,14 +135,6 @@ namespace AsbCloudInfrastructure.Services.SAUB
|
|||||||
result.Items.Add(messageDto);
|
result.Items.Add(messageDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sortFields?.Any() == true && !hasAllSortedFieldsInDBOType)
|
|
||||||
{
|
|
||||||
result.Items = result.Items.AsQueryable()
|
|
||||||
.SortBy(request.SortFields)
|
|
||||||
.Skip(skip)
|
|
||||||
.Take(take)
|
|
||||||
.ToList();
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user