zeroframework/Services/DeviceCenter/ZeroFramework.DeviceCenter.Domain/Specifications/Builder/OrderedBuilderExtensions.cs

28 lines
1.1 KiB
C#
Raw Normal View History

2023-12-05 09:22:48 +00:00
using System.Linq.Expressions;
namespace ZeroFramework.DeviceCenter.Domain.Specifications.Builder
{
public static class OrderedBuilderExtensions
{
public static IOrderedSpecificationBuilder<T> ThenBy<T>(
this IOrderedSpecificationBuilder<T> orderedBuilder,
Expression<Func<T, object?>> orderExpression)
{
((List<(Expression<Func<T, object?>> OrderExpression, OrderTypeEnum OrderType)>)orderedBuilder.Specification.OrderExpressions)
.Add((orderExpression, OrderTypeEnum.ThenBy));
return orderedBuilder;
}
public static IOrderedSpecificationBuilder<T> ThenByDescending<T>(
this IOrderedSpecificationBuilder<T> orderedBuilder,
Expression<Func<T, object?>> orderExpression)
{
((List<(Expression<Func<T, object?>> OrderExpression, OrderTypeEnum OrderType)>)orderedBuilder.Specification.OrderExpressions)
.Add((orderExpression, OrderTypeEnum.ThenByDescending));
return orderedBuilder;
}
}
}