INamedObject
This commit is contained in:
@@ -11,6 +11,8 @@ 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;
|
||||
|
||||
@@ -47,6 +49,8 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
|
||||
|
||||
protected virtual IQueryable<TEntity> SortEntities(IQueryable<TEntity> entities)
|
||||
{
|
||||
if (isNamedObjectType)
|
||||
return entities.OrderBy(n => ((INamedObject)n).Name);
|
||||
return entities;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Version>2.8.1</Version>
|
||||
<Version>2.8.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
6
Pilz/Data/INamedObject.cs
Normal file
6
Pilz/Data/INamedObject.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Pilz.Data;
|
||||
|
||||
public interface INamedObject
|
||||
{
|
||||
string Name { get; }
|
||||
}
|
||||
@@ -5,7 +5,7 @@
|
||||
<LangVersion>latest</LangVersion>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>annotations</Nullable>
|
||||
<Version>2.5.1</Version>
|
||||
<Version>2.5.2</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
|
||||
|
||||
Reference in New Issue
Block a user