return IOrderedQueryable and order by id by default
This commit is contained in:
@@ -19,6 +19,8 @@ public abstract class BaseHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
|
||||
public event EventHandler<TEntity>? OnDeleteItem;
|
||||
|
||||
protected readonly bool isNamedObjectType = typeof(TEntity).IsAssignableTo(typeof(INamedObject));
|
||||
|
||||
/// <summary>
|
||||
/// Gets the base route (endpoint) for the most API calls.
|
||||
/// </summary>
|
||||
@@ -102,6 +104,13 @@ public abstract class BaseHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
return entities;
|
||||
}
|
||||
|
||||
protected virtual IOrderedQueryable<TEntity> SortEntities(IQueryable<TEntity> entities)
|
||||
{
|
||||
if (isNamedObjectType)
|
||||
return entities.OrderBy(n => ((INamedObject)n).Name);
|
||||
return entities.OrderBy(n => n.Id);
|
||||
}
|
||||
|
||||
protected abstract ApiResult? UpdateEntity(EntityUpdate update);
|
||||
|
||||
protected abstract IDataObject ToClient(TEntity entity);
|
||||
|
||||
Reference in New Issue
Block a user