Sieve/Sieve.Sample/Services/SieveCustomSortMethods.cs

16 lines
495 B
C#
Raw Normal View History

2018-05-15 01:34:37 +02:00
using System.Linq;
using Sieve.Sample.Entities;
2018-05-15 01:34:37 +02:00
using Sieve.Services;
2018-01-27 07:37:38 +01:00
namespace Sieve.Sample.Services
2018-01-27 07:37:38 +01:00
{
2018-02-07 05:43:09 +01:00
public class SieveCustomSortMethods : ISieveCustomSortMethods
2018-01-27 07:37:38 +01:00
{
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)
2018-01-27 07:37:38 +01:00
.ThenBy(p => p.CommentCount)
.ThenBy(p => p.DateCreated);
}
}