return IOrderedQueryable and order by id by default
This commit is contained in:
@@ -11,8 +11,6 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
where TEntity : class, IDataObject
|
||||
where TUpdateMsg : ApiMessage
|
||||
{
|
||||
protected readonly bool isNamedObjectType = typeof(TEntity).IsAssignableTo(typeof(INamedObject));
|
||||
|
||||
protected virtual bool RegisterGetAll => true;
|
||||
protected virtual bool RegisterPost => true;
|
||||
|
||||
@@ -28,7 +26,7 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
|
||||
public virtual ApiResult GetAll(string? ids, int offset, int amount)
|
||||
{
|
||||
var entities = SortEntities(FilterByIDs(server.Manager.Get<TEntity>(), ids));
|
||||
var entities = (IQueryable<TEntity>)SortEntities(FilterByIDs(server.Manager.Get<TEntity>(), ids));
|
||||
if (offset > 0)
|
||||
entities = entities.Skip(offset);
|
||||
if (amount > 0)
|
||||
@@ -46,11 +44,4 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
return result2;
|
||||
return ToClient(entity).ToItemResult(HttpStatusCode.Created);
|
||||
}
|
||||
|
||||
protected virtual IQueryable<TEntity> SortEntities(IQueryable<TEntity> entities)
|
||||
{
|
||||
if (isNamedObjectType)
|
||||
return entities.OrderBy(n => ((INamedObject)n).Name);
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user