mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 12:02:35 +02:00
More better joins, some minor MDM changes for paging
This commit is contained in:
parent
32431540c5
commit
3602822572
@ -365,7 +365,7 @@ public virtual SortBuilder<T> Where<TObj>(Expression<Func<TObj, bool>> filterExp
|
||||
|
||||
public virtual SortBuilder<T> Where(Expression<Func<T, bool>> filterExpression)
|
||||
{
|
||||
_whereBuilder = new WhereBuilder<T>(_db.Command, _dialect, filterExpression, _tables, false, true);
|
||||
_whereBuilder = new WhereBuilder<T>(_db.Command, _dialect, filterExpression, _tables, _useAltName, true);
|
||||
return SortBuilder;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,12 @@ public virtual string BuildQuery(bool useAltName)
|
||||
}
|
||||
|
||||
string columnName = DataHelper.GetColumnName(sort.DeclaringType, sort.PropertyName, useAltName);
|
||||
sb.Append(_dialect.CreateToken(string.Format("{0}.{1}", table.Alias, columnName)));
|
||||
|
||||
if (!_useAltName)
|
||||
sb.Append(_dialect.CreateToken(string.Format("{0}.{1}", table.Alias, columnName)));
|
||||
|
||||
else
|
||||
sb.Append(_dialect.CreateToken(string.Format("{0}", columnName)));
|
||||
|
||||
if (sort.Direction == SortDirection.Desc)
|
||||
sb.Append(" DESC");
|
||||
|
@ -182,7 +182,12 @@ protected string GetFullyQualifiedColumnName(MemberInfo member, Type declaringTy
|
||||
}
|
||||
|
||||
string columnName = DataHelper.GetColumnName(declaringType, member.Name, _useAltName);
|
||||
return _dialect.CreateToken(string.Format("{0}.{1}", table.Alias, columnName));
|
||||
|
||||
if (!_useAltName)
|
||||
return _dialect.CreateToken(string.Format("{0}.{1}", table.Alias, columnName));
|
||||
|
||||
else
|
||||
return _dialect.CreateToken(string.Format("{0}", columnName));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -23,6 +23,7 @@ public static class MappingExtensions
|
||||
return mapBuilder.Table.MapTable(tableName)
|
||||
.Columns
|
||||
.AutoMapPropertiesWhere(IsMappableProperty)
|
||||
.PrefixAltNames(String.Format("{0}_", typeof(T).Name))
|
||||
.For(c => c.Id)
|
||||
.SetPrimaryKey()
|
||||
.SetReturnValue()
|
||||
|
@ -52,7 +52,8 @@ public static void Map()
|
||||
Mapper.Entity<Season>().RegisterModel("Seasons");
|
||||
|
||||
Mapper.Entity<Episode>().RegisterModel("Episodes")
|
||||
.Ignore(e => e.SeriesTitle);
|
||||
.Ignore(e => e.SeriesTitle)
|
||||
.Relationships.AutoMapICollectionOrComplexProperties();
|
||||
|
||||
Mapper.Entity<EpisodeFile>().RegisterModel("EpisodeFiles");
|
||||
|
||||
|
@ -75,14 +75,15 @@ public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec,
|
||||
startingSeasonNumber = 0;
|
||||
}
|
||||
|
||||
pagingSpec.Records = Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
||||
var pagingQuery = Query.Join<Episode, Series>(JoinType.Inner, e => e.Series, (e, s) => e.SeriesId == s.Id)
|
||||
.Where(e => e.EpisodeFileId == 0)
|
||||
.AndWhere(e => e.SeasonNumber >= startingSeasonNumber)
|
||||
.AndWhere(e => e.AirDate <= currentTime)
|
||||
.OrderBy(pagingSpec.OrderByClause(), pagingSpec.ToSortDirection())
|
||||
.Skip(pagingSpec.PagingOffset())
|
||||
.Take(pagingSpec.PageSize)
|
||||
.ToList();
|
||||
.Take(pagingSpec.PageSize);
|
||||
|
||||
pagingSpec.Records = pagingQuery.ToList();
|
||||
|
||||
//TODO: Use the same query for count and records
|
||||
pagingSpec.TotalRecords = Query.Where(e => e.EpisodeFileId == 0 && e.SeasonNumber >= startingSeasonNumber && e.AirDate <= currentTime).Count();
|
||||
|
@ -99,8 +99,6 @@ public PagingSpec<Episode> EpisodesWithoutFiles(PagingSpec<Episode> pagingSpec,
|
||||
{
|
||||
var episodeResult = _episodeRepository.EpisodesWithoutFiles(pagingSpec, includeSpecials);
|
||||
|
||||
episodeResult.Records = LinkSeriesToEpisodes(episodeResult.Records);
|
||||
|
||||
return episodeResult;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user