Merge pull request #1 from krivulcik/connection-string-support
Connection string support
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
.localhistory
|
||||
.nupkg
|
||||
|
||||
# User-specific files
|
||||
|
||||
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user