From e898bf6f0b33471390a8e75ce828bd4f7a305873 Mon Sep 17 00:00:00 2001 From: JudahGabriel Date: Sat, 10 Feb 2018 22:31:35 -0600 Subject: [PATCH] Added method to create doc session using injected doc store. --- RavenDB.Identity/RavenDB.Identity.csproj | 4 ++-- .../ServiceCollectionExtensions.cs | 21 +++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/RavenDB.Identity/RavenDB.Identity.csproj b/RavenDB.Identity/RavenDB.Identity.csproj index df469ea..2230ff0 100644 --- a/RavenDB.Identity/RavenDB.Identity.csproj +++ b/RavenDB.Identity/RavenDB.Identity.csproj @@ -14,11 +14,11 @@ https://github.com/JudahGabriel/RavenDB.Identity https://github.com/JudahGabriel/RavenDB.Identity/blob/master/LICENSE.md https://github.com/JudahGabriel/RavenDB.Identity/blob/master/RavenDB.Identity/nuget-icon.png?raw=true - Copyright 2017 BitShuva + Copyright 2018 BitShuva false false false - 4.0.0 + 4.0.1 False diff --git a/RavenDB.Identity/ServiceCollectionExtensions.cs b/RavenDB.Identity/ServiceCollectionExtensions.cs index 602d691..f76c3b8 100644 --- a/RavenDB.Identity/ServiceCollectionExtensions.cs +++ b/RavenDB.Identity/ServiceCollectionExtensions.cs @@ -81,5 +81,26 @@ namespace Raven.Identity serviceCollection.Add(new ServiceDescriptor(typeof(IAsyncDocumentSession), p => db.OpenAsyncSession(), ServiceLifetime.Scoped)); return serviceCollection; } + + /// + /// Registers a RavenDB to be created and disposed on each request. + /// This requires for an to be added to dependency injection services. + /// + /// + /// + /// public void ConfigureServices(IServiceCollection services) + /// { + /// services.AddRavenDbAsyncSession(); + /// } + /// + /// + /// The to add services to. + /// Based on code from https://github.com/maqduni/AspNetCore.Identity.RavenDb/blob/master/src/Maqduni.AspNetCore.Identity.RavenDb/RavenDbServiceCollectionExtensions.cs + /// The same service collection so that multiple calls can be chained. + public static IServiceCollection AddRavenDbAsyncSession(this IServiceCollection serviceCollection) + { + serviceCollection.Add(new ServiceDescriptor(typeof(IAsyncDocumentSession), p => p.GetRequiredService().OpenAsyncSession(), ServiceLifetime.Scoped)); + return serviceCollection; + } } }