Sieve/Sieve.Sample/Services/SieveCustomSortMethods.cs
ITDancer139 428acd7558 * Migrate tests to xunit
* Update sample project to dotnetcore3.1
* Use Sqlite in sample project to run it everywhere
* Fix: Filter with escaped comma
* Fix: Filter "null" does not work with Contains or StartsWith
* Code cleanup: Adjust namespaces, adjust usings
2021-05-13 14:04:18 +02:00

16 lines
495 B
C#

using System.Linq;
using Sieve.Sample.Entities;
using Sieve.Services;
namespace Sieve.Sample.Services
{
public class SieveCustomSortMethods : ISieveCustomSortMethods
{
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);
}
}