Support connecting using connection string

This commit is contained in:
Andrej Krivulčík
2015-11-02 14:54:07 +01:00
parent 20709dcb6e
commit 15709688d4
2 changed files with 26 additions and 3 deletions
+14 -3
View File
@@ -19,6 +19,7 @@ namespace HangFire.Raven
{
public class Repository : IDisposable
{
public static string ConnectionString { get; set; }
public static string ConnectionUrl { get; set; }
public static string DefaultDatabase { get; set; }
@@ -62,10 +63,20 @@ namespace HangFire.Raven
((EmbeddableDocumentStore)_documentStore).Configuration.Storage.Voron.AllowOn32Bits = true;
} else {
_documentStore = new DocumentStore
if (!string.IsNullOrEmpty(ConnectionString))
{
Url = ConnectionUrl
};
_documentStore = new DocumentStore
{
ConnectionStringName = ConnectionString
};
}
else
{
_documentStore = new DocumentStore
{
Url = ConnectionUrl
};
}
}
_documentStore.Conventions.DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite;
@@ -24,6 +24,18 @@ namespace HangFire.Raven.Storage
{
public static class SqlServerStorageExtensions
{
public static IGlobalConfiguration<RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionString)
{
configuration.ThrowIfNull("configuration");
connectionString.ThrowIfNull("connectionString");
Repository.ConnectionString = connectionString;
var storage = new RavenStorage();
return configuration.UseStorage(storage);
}
public static IGlobalConfiguration<RavenStorage> UseRavenStorage(this IGlobalConfiguration configuration, string connectionUrl, string database)
{
configuration.ThrowIfNull("configuration");