Generator Changes at 9/27/2025 8:46:36 AM
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
using System.Linq.Dynamic.Core;
|
||||
using CMSMicroservice.Domain.Common;
|
||||
|
||||
namespace CMSMicroservice.Application.Common.Extensions;
|
||||
|
||||
public static class SortByExtensions
|
||||
{
|
||||
public static IQueryable<TSource> ApplyOrder<TSource>(this IQueryable<TSource> source,
|
||||
string? sortBy) where TSource : BaseAuditableEntity
|
||||
{
|
||||
// default sort approach
|
||||
if (sortBy is null or "")
|
||||
{
|
||||
source = source.OrderByDescending(p => p.Created);
|
||||
return source;
|
||||
}
|
||||
|
||||
// sort using dynamic linq
|
||||
source = source.OrderBy(sortBy);
|
||||
|
||||
return source;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user