diff --git a/NzbDrone.Core.Test/Eloquera.config b/NzbDrone.Core.Test/Eloquera.config
new file mode 100644
index 000000000..5ae536d21
--- /dev/null
+++ b/NzbDrone.Core.Test/Eloquera.config
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
diff --git a/NzbDrone.Core.Test/Framework/SqlCeTest.cs b/NzbDrone.Core.Test/Framework/SqlCeTest.cs
index 94a8fe2c3..61e037214 100644
--- a/NzbDrone.Core.Test/Framework/SqlCeTest.cs
+++ b/NzbDrone.Core.Test/Framework/SqlCeTest.cs
@@ -32,8 +32,8 @@ namespace NzbDrone.Core.Test.Framework
public abstract class ObjectDbTest : CoreTest
{
- private IObjectDbSession _db;
- protected IObjectDbSession Db
+ private EloqueraDb _db;
+ protected EloqueraDb Db
{
get
{
@@ -48,11 +48,12 @@ namespace NzbDrone.Core.Test.Framework
{
if (memory)
{
- _db = new ObjectDbSessionFactory().Create(new PagingMemoryStorage());
+ //Todo: Actually use memory: http://www.eloquera.com/sites/default/files/filepicker/1/Help/Documentation/HTML/In-memory%20database.htm
+ _db = new EloqueraDbFactory().Create();
}
else
{
- _db = new ObjectDbSessionFactory().Create(dbName: Guid.NewGuid().ToString());
+ _db = new EloqueraDbFactory().Create(dbFilename: Guid.NewGuid().ToString());
}
Mocker.SetConstant(Db);
diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
index 78d934a20..8166e73a6 100644
--- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
+++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj
@@ -78,6 +78,15 @@
False
..\Libraries\DeskMetrics\DeskMetrics.NET.dll
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Client.dll
+
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Common.dll
+
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Server.exe
+
..\packages\NBuilder.3.0.1.1\lib\FizzWare.NBuilder.dll
@@ -317,6 +326,7 @@
Always
+
Always
diff --git a/NzbDrone.Core.Test/packages.config b/NzbDrone.Core.Test/packages.config
index ca7aad22c..8d13db8e9 100644
--- a/NzbDrone.Core.Test/packages.config
+++ b/NzbDrone.Core.Test/packages.config
@@ -4,6 +4,7 @@
+
diff --git a/NzbDrone.Core/Datastore/DbProviderFactory.cs b/NzbDrone.Core/Datastore/DbProviderFactory.cs
index c34673469..865d97418 100644
--- a/NzbDrone.Core/Datastore/DbProviderFactory.cs
+++ b/NzbDrone.Core/Datastore/DbProviderFactory.cs
@@ -1,7 +1,6 @@
using System;
using System.Data.Common;
using System.Data.SqlServerCe;
-using Db4objects.Db4o.Internal.Config;
using StackExchange.Profiling;
using StackExchange.Profiling.Data;
diff --git a/NzbDrone.Core/Datastore/EloqueraDb.cs b/NzbDrone.Core/Datastore/EloqueraDb.cs
new file mode 100644
index 000000000..a6dc1b0a0
--- /dev/null
+++ b/NzbDrone.Core/Datastore/EloqueraDb.cs
@@ -0,0 +1,89 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Eloquera.Client;
+
+namespace NzbDrone.Core.Datastore
+{
+ public class EloqueraDb : IDisposable
+ {
+ private DB _db;
+
+ public EloqueraDb(DB db)
+ {
+ _db = db;
+ }
+
+ public int Create(object obj)
+ {
+ return Convert.ToInt32(_db.Store(obj));
+ }
+
+ public void Update(object obj)
+ {
+ _db.Store(obj);
+ }
+
+ public void Delete(object obj)
+ {
+ _db.Delete(obj);
+ }
+
+ public void DeleteAll(object obj)
+ {
+ _db.DeleteAll(obj);
+ }
+
+ public IEnumerable Query()
+ {
+ return _db.Query();
+ }
+
+ public IEnumerable ExecuteQuery(string query)
+ {
+ return _db.ExecuteQuery(query);
+ }
+
+ public IEnumerable ExecuteQuery(string query, int depth)
+ {
+ return _db.ExecuteQuery(query, depth);
+ }
+
+ public IEnumerable ExecuteQuery(string query, int depth, Parameters parameters)
+ {
+ return _db.ExecuteQuery(query, depth, parameters);
+ }
+
+ public IEnumerable ExecuteQuery(string query, Parameters parameters)
+ {
+ return _db.ExecuteQuery(query, parameters);
+ }
+
+ public object ExecutScalar(string query)
+ {
+ return _db.ExecuteQuery(query);
+ }
+
+ public object ExecuteScalar(string query, int depth)
+ {
+ return _db.ExecuteQuery(query, depth);
+ }
+
+ public object ExecuteScalar(string query, int depth, Parameters parameters)
+ {
+ return _db.ExecuteQuery(query, depth, parameters);
+ }
+
+ public object ExecuteScalar(string query, Parameters parameters)
+ {
+ return _db.ExecuteQuery(query, parameters);
+ }
+
+ public void Dispose()
+ {
+ _db.Dispose();
+ }
+ }
+}
diff --git a/NzbDrone.Core/Datastore/EloqueraDbFactory.cs b/NzbDrone.Core/Datastore/EloqueraDbFactory.cs
new file mode 100644
index 000000000..77e3e5544
--- /dev/null
+++ b/NzbDrone.Core/Datastore/EloqueraDbFactory.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using Eloquera.Client;
+using NzbDrone.Common;
+
+namespace NzbDrone.Core.Datastore
+{
+ public class EloqueraDbFactory
+ {
+ private readonly EnvironmentProvider _environmentProvider;
+
+ public EloqueraDbFactory()
+ {
+ _environmentProvider = new EnvironmentProvider();
+ }
+
+ public EloqueraDb Create(string dbName = "NzbDrone", string dbFilename = "nzbdrone.eloq")
+ {
+ DB db = new DB();
+ DB.Configuration.ServerSettings.DatabasePath = Path.Combine(_environmentProvider.GetAppDataPath(), dbName);
+ db.CreateDatabase(dbName);
+ db.OpenDatabase(dbName);
+ db.RefreshMode = ObjectRefreshMode.AlwaysReturnUpdatedValues;
+
+ return new EloqueraDb(db);
+ }
+ }
+}
diff --git a/NzbDrone.Core/Datastore/NoCacheReferenceSystem.cs b/NzbDrone.Core/Datastore/NoCacheReferenceSystem.cs
deleted file mode 100644
index c645f0599..000000000
--- a/NzbDrone.Core/Datastore/NoCacheReferenceSystem.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System.Linq;
-using Db4objects.Db4o.Internal;
-using Db4objects.Db4o.Internal.References;
-
-namespace NzbDrone.Core.Datastore
-{
- public class NoCacheReferenceSystem : HashcodeReferenceSystem
- {
- public override ObjectReference ReferenceForId(int id)
- {
- //never return an in memory instance of objects as query result. always go to db.
- return null;
- }
- }
-}
diff --git a/NzbDrone.Core/Datastore/ObjectDbSession.cs b/NzbDrone.Core/Datastore/ObjectDbSession.cs
deleted file mode 100644
index ba11a6ceb..000000000
--- a/NzbDrone.Core/Datastore/ObjectDbSession.cs
+++ /dev/null
@@ -1,127 +0,0 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using Db4objects.Db4o;
-using Db4objects.Db4o.Internal;
-
-namespace NzbDrone.Core.Datastore
-{
- public interface IObjectDbSession : IObjectContainer
- {
- void Create(object obj);
- void Create(object obj, int depth);
- void SaveAll(Transaction transaction, IEnumerator objects);
-
- void Update(object obj);
- void Update(object obj, int depth);
- void UpdateAll(Transaction transaction, IEnumerator objects);
- }
-
-
- public class ObjectDbSession : ObjectContainerSession, IObjectDbSession
- {
-
- public ObjectDbSession(ObjectContainerBase server)
- : base(server, server.NewTransaction(server.SystemTransaction(), new NoCacheReferenceSystem(), false))
- {
- _transaction.SetOutSideRepresentation(this);
- }
-
- public override void Store(object obj)
- {
- throw new InvalidOperationException("Store is not supported. please use Create() or Update()");
- }
-
- public override void StoreAll(Transaction transaction, IEnumerator objects)
- {
- throw new InvalidOperationException("Store is not supported. please use Create() or Update()");
-
- }
-
- public override void Store(object obj, int depth)
- {
- throw new InvalidOperationException("Store is not supported. please use Create() or Update()");
- }
-
- public void Create(object obj)
- {
- ValidateCreate(obj);
- base.Store(obj);
- }
-
- public void Create(object obj, int depth)
- {
- ValidateCreate(obj);
- base.Store(obj, depth);
- }
-
- public void SaveAll(Transaction transaction, IEnumerator objects)
- {
- var obj = objects.ToIEnumerable().ToList();
- obj.ForEach(c => ValidateCreate(c));
-
- base.StoreAll(transaction, obj.GetEnumerator());
- }
-
-
- public void Update(object obj)
- {
- ValidateUpdate(obj);
- base.Store(obj);
- }
-
- public void Update(object obj, int depth)
- {
- ValidateUpdate(obj);
- base.Store(obj, depth);
- }
-
- public void UpdateAll(Transaction transaction, IEnumerator objects)
- {
- var obj = objects.ToIEnumerable().ToList();
- obj.ForEach(c => ValidateUpdate(c));
-
- base.StoreAll(transaction, obj.GetEnumerator());
- }
-
- public void UpdateAll(Transaction transaction, IEnumerator objects)
- {
- throw new NotImplementedException();
- }
-
-
- private void ValidateCreate(object obj)
- {
- if (IsAttached(obj))
- {
- throw new InvalidOperationException("Attempted to save an object that is already attached to database");
- }
- }
-
- private void ValidateUpdate(object obj)
- {
- if (!IsAttached(obj))
- {
- throw new InvalidOperationException("Attempted to update an object that is not attached to database");
- }
- }
-
- private bool IsAttached(object obj)
- {
- return base.Ext().GetID(obj) > 0;
- }
- }
-
-
- public static class Ext
- {
- public static IEnumerable ToIEnumerable(this IEnumerator enumerator)
- {
- while (enumerator.MoveNext())
- {
- yield return enumerator.Current;
- }
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core/Datastore/ObjectDbSessionFactory.cs b/NzbDrone.Core/Datastore/ObjectDbSessionFactory.cs
deleted file mode 100644
index 00262ae2c..000000000
--- a/NzbDrone.Core/Datastore/ObjectDbSessionFactory.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using System.Linq;
-using Db4objects.Db4o;
-using Db4objects.Db4o.IO;
-using Db4objects.Db4o.Internal;
-
-namespace NzbDrone.Core.Datastore
-{
- public class ObjectDbSessionFactory
- {
- public IObjectDbSession Create(IStorage storage = null, string dbName = "nzbdrone.db4o")
- {
- if (storage == null)
- {
- storage = new FileStorage();
- }
-
- var config = Db4oEmbedded.NewConfiguration();
- config.File.Storage = storage;
-
-
- var objectContainer = Db4oEmbedded.OpenFile(config, dbName);
- return new ObjectDbSession((ObjectContainerBase)objectContainer);
- }
- }
-}
\ No newline at end of file
diff --git a/NzbDrone.Core/Eloquera.config b/NzbDrone.Core/Eloquera.config
new file mode 100644
index 000000000..5ae536d21
--- /dev/null
+++ b/NzbDrone.Core/Eloquera.config
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj
index c5c15ffe3..56b2b5300 100644
--- a/NzbDrone.Core/NzbDrone.Core.csproj
+++ b/NzbDrone.Core/NzbDrone.Core.csproj
@@ -133,17 +133,17 @@
False
..\packages\DataTables.Mvc.Core.0.1.0.85\lib\DataTables.Mvc.Core.dll
-
- ..\packages\db4o-devel.8.1.184.15492\lib\net40\Db4objects.Db4o.dll
+
+ ..\Libraries\DeskMetrics\DeskMetrics.NET.dll
-
- ..\packages\db4o-devel.8.1.184.15492\lib\net40\Db4objects.Db4o.Data.Services.dll
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Client.dll
-
- ..\packages\db4o-devel.8.1.184.15492\lib\net40\Db4objects.Db4o.Linq.dll
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Common.dll
-
- ..\Libraries\DeskMetrics\DeskMetrics.NET.dll
+
+ ..\packages\EloqueraDB.5.0.0\lib\net40\Eloquera.Server.exe
..\packages\Growl.0.6\lib\Growl.Connector.dll
@@ -177,9 +177,6 @@
..\packages\MiniProfiler.2.0.2\lib\net40\MiniProfiler.dll
-
- ..\packages\db4o-devel.8.1.184.15492\lib\net40\Mono.Reflection.dll
-
False
..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll
@@ -235,8 +232,8 @@
-
-
+
+
@@ -270,7 +267,6 @@
-
@@ -644,6 +640,7 @@
+
diff --git a/NzbDrone.Core/packages.config b/NzbDrone.Core/packages.config
index 41f27a466..ea2b9747e 100644
--- a/NzbDrone.Core/packages.config
+++ b/NzbDrone.Core/packages.config
@@ -2,8 +2,8 @@
-
+
diff --git a/NzbDrone.ncrunchsolution b/NzbDrone.ncrunchsolution
index e88d63cdb..13a4b6131 100644
--- a/NzbDrone.ncrunchsolution
+++ b/NzbDrone.ncrunchsolution
@@ -2,7 +2,6 @@
1
False
true
- true
UseDynamicAnalysis
Disabled
Disabled