diff --git a/NzbDrone.Core/Datastore/MappingExtensions.cs b/NzbDrone.Core/Datastore/MappingExtensions.cs index 468f6bfdf..efd23f909 100644 --- a/NzbDrone.Core/Datastore/MappingExtensions.cs +++ b/NzbDrone.Core/Datastore/MappingExtensions.cs @@ -1,16 +1,27 @@ using System; -using System.Collections.Generic; -using System.Linq; using System.Reflection; using Marr.Data; using Marr.Data.Mapping; +using NzbDrone.Core.Tv; namespace NzbDrone.Core.Datastore { public static class MappingExtensions { - public static ColumnMapBuilder RegisterModel(this FluentMappings.MappingsFluentEntity mapBuilder, string tableName) where T : ModelBase + + public static ColumnMapBuilder MapResultSet(this FluentMappings.MappingsFluentEntity mapBuilder) where T : ResultSet, new() { + return mapBuilder + .Columns + .AutoMapPropertiesWhere(IsMappableProperty); + } + + + public static ColumnMapBuilder RegisterModel(this FluentMappings.MappingsFluentEntity mapBuilder, string tableName = null) where T : ModelBase, new() + { + + + return mapBuilder.Table.MapTable(tableName) .Columns .AutoMapPropertiesWhere(IsMappableProperty) diff --git a/NzbDrone.Core/Datastore/ResultSet.cs b/NzbDrone.Core/Datastore/ResultSet.cs new file mode 100644 index 000000000..2bb2b4169 --- /dev/null +++ b/NzbDrone.Core/Datastore/ResultSet.cs @@ -0,0 +1,6 @@ +namespace NzbDrone.Core.Datastore +{ + public class ResultSet + { + } +} \ No newline at end of file diff --git a/NzbDrone.Core/Datastore/TableMapping.cs b/NzbDrone.Core/Datastore/TableMapping.cs index a133e67f3..c11027d79 100644 --- a/NzbDrone.Core/Datastore/TableMapping.cs +++ b/NzbDrone.Core/Datastore/TableMapping.cs @@ -57,9 +57,7 @@ namespace NzbDrone.Core.Datastore Mapper.Entity().RegisterModel("Logs"); - Mapper.Entity() - .Columns - .AutoMapPropertiesWhere(MappingExtensions.IsMappableProperty); + Mapper.Entity().MapResultSet(); } diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index 0949857c7..33d629786 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -356,6 +356,7 @@ + diff --git a/NzbDrone.Core/Tv/SeriesRepository.cs b/NzbDrone.Core/Tv/SeriesRepository.cs index 023365510..624ce030c 100644 --- a/NzbDrone.Core/Tv/SeriesRepository.cs +++ b/NzbDrone.Core/Tv/SeriesRepository.cs @@ -65,7 +65,7 @@ namespace NzbDrone.Core.Tv SUM(CASE WHEN Airdate <= @currentDate THEN 1 ELSE 0 END) AS EpisodeCount, SUM(CASE WHEN EpisodeFileId > 0 AND AirDate <= @currentDate THEN 1 ELSE 0 END) as EpisodeFileCount, MAX(SeasonNumber) as NumberOfSeasons, - MIN(CASE WHEN AirDate < @currentDate THEN NULL ELSE AirDate END) as NextAiring + MIN(CASE WHEN AirDate < @currentDate THEN NULL ELSE AirDate END) as NextAiringString FROM Episodes WHERE Ignored = 0 GROUP BY SeriesId"; diff --git a/NzbDrone.Core/Tv/SeriesStatistics.cs b/NzbDrone.Core/Tv/SeriesStatistics.cs index 5e9bfc228..a1d113026 100644 --- a/NzbDrone.Core/Tv/SeriesStatistics.cs +++ b/NzbDrone.Core/Tv/SeriesStatistics.cs @@ -1,12 +1,17 @@ using System; +using NzbDrone.Core.Datastore; namespace NzbDrone.Core.Tv { - public class SeriesStatistics + public class SeriesStatistics : ResultSet { public int SeriesId { get; set; } public int NumberOfSeasons { get; set; } - public DateTime? NextAiring { get; set; } + public string NextAiringString { get; set; } + public DateTime? NextAiring + { + get { return Convert.ToDateTime(NextAiringString); } + } public int EpisodeFileCount { get; set; } public int EpisodeCount { get; set; } }