zeroframework/Services/DeviceCenter/ZeroFramework.DeviceCenter.Domain/Specifications/Builder/OrderedBuilderExtensions.cs
2023-12-05 17:22:48 +08:00

28 lines
1.1 KiB
C#

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;
}
}
}