INamedObject

This commit is contained in:
Pilzinsel64
2025-10-29 06:07:48 +01:00
parent 4922f0a516
commit 3f5153c497
4 changed files with 12 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ public abstract class BaseItemHandler<TEntity, TUpdateMsg>(IApiServer server)
where TEntity : class, IDataObject where TEntity : class, IDataObject
where TUpdateMsg : ApiMessage where TUpdateMsg : ApiMessage
{ {
protected readonly bool isNamedObjectType = typeof(TEntity).IsAssignableTo(typeof(INamedObject));
protected virtual bool RegisterGetAll => true; protected virtual bool RegisterGetAll => true;
protected virtual bool RegisterPost => 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) protected virtual IQueryable<TEntity> SortEntities(IQueryable<TEntity> entities)
{ {
if (isNamedObjectType)
return entities.OrderBy(n => ((INamedObject)n).Name);
return entities; return entities;
} }
} }

View File

@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<Version>2.8.1</Version> <Version>2.8.2</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@@ -0,0 +1,6 @@
namespace Pilz.Data;
public interface INamedObject
{
string Name { get; }
}

View File

@@ -5,7 +5,7 @@
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>annotations</Nullable> <Nullable>annotations</Nullable>
<Version>2.5.1</Version> <Version>2.5.2</Version>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> <PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">