mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-05-24 02:02:36 -04:00
Working on the sortBy
This commit is contained in:
parent
aa63c9e8f2
commit
4357d599e4
@ -46,12 +46,14 @@ namespace Kyoo.Controllers
|
||||
|
||||
string key = sortBy.Contains(':') ? sortBy.Substring(0, sortBy.IndexOf(':')) : sortBy;
|
||||
string order = sortBy.Contains(':') ? sortBy.Substring(sortBy.IndexOf(':') + 1) : null;
|
||||
|
||||
Key = Expression.Lambda<Func<T, object>>(Expression.Property(Expression.Parameter(typeof(T), "x"), key));
|
||||
|
||||
ParameterExpression param = Expression.Parameter(typeof(T), "x");
|
||||
Key = Expression.Lambda<Func<T, object>>(Expression.Property(param, key), param);
|
||||
Descendant = order switch
|
||||
{
|
||||
"desc" => true,
|
||||
"asc" => false,
|
||||
"" => false,
|
||||
_ => throw new ArgumentException($"The sort order, if set, should be :asc or :desc but it was :{order}.")
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user