Created
October 30, 2020 15:05
-
-
Save gistlyn/e85f214f80dff349a834b8607e4e841d to your computer and use it in GitHub Desktop.
marten files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dotnet add package RavenDB.Client |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Generic; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
using ServiceStack; | |
using Marten; | |
namespace MyApp | |
{ | |
public class ConfigureMarten : IConfigureServices | |
{ | |
public static List<StoreOptions> Options { get; } = new List<StoreOptions>(); | |
IConfiguration Configuration { get; } | |
public ConfigureDb(IConfiguration configuration) => Configuration = configuration; | |
public void Configure(IServiceCollection services) | |
{ | |
var store = DocumentStore.For(opts => | |
{ | |
opts.Connection(Configuration.GetConnectionString("Marten") | |
?? "host=localhost;username=test;password=test;database=marten"); | |
Options.ForEach(fn => fn(opts)); | |
}); | |
store.Advanced.Clean.CompletelyRemoveAll(); | |
services.AddSingleton<IDocumentStore>(store); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment