mirror of
https://github.com/lidarr/lidarr.git
synced 2025-08-19 21:13:28 -07:00
First steps for SQLite
This commit is contained in:
parent
29ec800996
commit
ebbf5ea21f
10 changed files with 231 additions and 29 deletions
|
@ -1,50 +1,50 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common;
|
||||
using NzbDrone.Core.Datastore;
|
||||
using ServiceStack.OrmLite;
|
||||
|
||||
namespace NzbDrone.Core.Tv
|
||||
{
|
||||
public interface ISeriesRepository : IBasicRepository<Series>
|
||||
public interface ISeriesRepository : IBasicDb<Series>
|
||||
{
|
||||
bool SeriesPathExists(string path);
|
||||
List<Series> Search(string title);
|
||||
Series GetByTitle(string cleanTitle);
|
||||
Series FindByTvdbId(int tvdbId);
|
||||
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
|
||||
|
||||
}
|
||||
|
||||
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
|
||||
public class SeriesRepository : BasicDb<Series>, ISeriesRepository
|
||||
{
|
||||
public SeriesRepository(IObjectDatabase objectDatabase)
|
||||
: base(objectDatabase)
|
||||
public SeriesRepository(IDbConnection database)
|
||||
: base(database)
|
||||
{
|
||||
}
|
||||
|
||||
public bool SeriesPathExists(string path)
|
||||
{
|
||||
return Queryable.Any(s => DiskProvider.PathEquals(s.Path, path));
|
||||
return Database.Exists<Series>("WHERE Path = {0}", path);
|
||||
}
|
||||
|
||||
public List<Series> Search(string title)
|
||||
{
|
||||
return Queryable.Where(s => s.Title.Contains(title)).ToList();
|
||||
return Database.Select<Series>(s => s.Title.Contains(title));
|
||||
}
|
||||
|
||||
public Series GetByTitle(string cleanTitle)
|
||||
{
|
||||
return Queryable.SingleOrDefault(s => s.CleanTitle.Equals(cleanTitle));
|
||||
return Database.Select<Series>(s => s.CleanTitle.Equals(cleanTitle)).SingleOrDefault();
|
||||
}
|
||||
|
||||
public Series FindByTvdbId(int tvdbId)
|
||||
{
|
||||
return Queryable.SingleOrDefault(s => s.TvDbId == tvdbId);
|
||||
return Database.Select<Series>(s => s.TvDbId.Equals(tvdbId)).SingleOrDefault();
|
||||
}
|
||||
|
||||
public void SetSeriesType(int seriesId, SeriesTypes seriesTypes)
|
||||
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
|
||||
{
|
||||
ObjectDatabase.UpdateField(new Series(){Id = seriesId, SeriesTypes =seriesTypes }, "SeriesType");
|
||||
Database.UpdateOnly(new Series { SeriesType = seriesType }, s => s.SeriesType, s => s.Id == seriesId);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue