using System; using System.Collections.Generic; using System.Linq; using Eloquera.Client; namespace NzbDrone.Core.Datastore { public class EloqueraDb : IDisposable { private readonly DB _db; public EloqueraDb(DB db) { _db = db; } public IEnumerable AsQueryable() { return _db.Query(); } public T Insert(T obj) { _db.Store(obj); return obj; } public IList InsertMany(IEnumerable objects) { return DoMany(objects, Insert); } public T Update(T obj) { _db.Store(obj); return obj; } public IList UpdateMany(IEnumerable objects) { return DoMany(objects, Update); } public void Delete(T obj) where T : new() { _db.Delete(obj); } public void DeleteMany(IEnumerable objects) where T: new() { foreach (var o in objects) { Delete(o); } } private IList DoMany(IEnumerable objects, Func function) { return objects.Select(function).ToList(); } public void Dispose() { _db.Dispose(); } } }