Sieve/SieveUnitTests/Services/SieveCustomSortMethods.cs

16 lines
499 B
C#
Raw Normal View History

2018-05-15 01:34:37 +02:00
using System.Linq;
using Sieve.Services;
using SieveUnitTests.Entities;
namespace SieveUnitTests.Services
{
public class SieveCustomSortMethods : ISieveCustomSortMethods
{
2018-05-15 01:34:37 +02:00
public IQueryable<Post> Popularity(IQueryable<Post> source, bool useThenBy) => useThenBy
? ((IOrderedQueryable<Post>)source).ThenBy(p => p.LikeCount)
: source.OrderBy(p => p.LikeCount)
.ThenBy(p => p.CommentCount)
.ThenBy(p => p.DateCreated);
}
}