mirror of
https://github.com/Radarr/Radarr.git
synced 2025-04-24 06:27:08 -04:00
Fixed: Radarr not loading with an invalid sort key.
This commit is contained in:
parent
b593c9272e
commit
30796388b0
3 changed files with 17 additions and 5 deletions
|
@ -259,7 +259,7 @@ namespace NzbDrone.Core.Datastore
|
|||
protected virtual SortBuilder<TModel> GetPagedQuery(QueryBuilder<TModel> query, PagingSpec<TModel> pagingSpec)
|
||||
{
|
||||
return query.Where(pagingSpec.FilterExpression)
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection());
|
||||
.OrderBy(pagingSpec.OrderByClause(x => x.Id), pagingSpec.ToSortDirection());
|
||||
}
|
||||
|
||||
protected void ModelCreated(TModel model)
|
||||
|
|
|
@ -6,9 +6,21 @@ namespace NzbDrone.Core.Datastore.Extensions
|
|||
{
|
||||
public static class PagingSpecExtensions
|
||||
{
|
||||
public static Expression<Func<TModel, object>> OrderByClause<TModel>(this PagingSpec<TModel> pagingSpec)
|
||||
public static Expression<Func<TModel, object>> OrderByClause<TModel>(this PagingSpec<TModel> pagingSpec, Expression<Func<TModel, object>> defaultExpression = null)
|
||||
{
|
||||
return CreateExpression<TModel>(pagingSpec.SortKey);
|
||||
try
|
||||
{
|
||||
return CreateExpression<TModel>(pagingSpec.SortKey);
|
||||
}
|
||||
catch
|
||||
{
|
||||
if (defaultExpression == null)
|
||||
{
|
||||
return x => x;
|
||||
}
|
||||
return defaultExpression;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static int PagingOffset<TModel>(this PagingSpec<TModel> pagingSpec)
|
||||
|
|
|
@ -161,7 +161,7 @@ namespace NzbDrone.Core.Movies
|
|||
{
|
||||
return Query.Where(pagingSpec.FilterExpression)
|
||||
.AndWhere(m => m.MovieFileId == 0)
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.OrderBy(pagingSpec.OrderByClause(x => x.SortTitle), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ namespace NzbDrone.Core.Movies
|
|||
return Query.Where(pagingSpec.FilterExpression)
|
||||
.AndWhere(m => m.MovieFileId != 0)
|
||||
.AndWhere(BuildQualityCutoffWhereClause(qualitiesBelowCutoff))
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.OrderBy(pagingSpec.OrderByClause(x => x.SortTitle), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue