RavenDBClientExtension Methods
ClassMethods4 members
Extension methods for connecting RavenDB database.
AddKeyedRavenDBClient(IHostApplicationBuilder, object, string, Action<RavenDBClientSettings>)Section titled AddKeyedRavenDBClient(IHostApplicationBuilder, object, string, Action<RavenDBClientSettings>)extension Registers
Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client, identified by a unique service key. public static class RavenDBClientExtension{ public static void AddKeyedRavenDBClient( this IHostApplicationBuilder builder, object serviceKey, string connectionName, Action<RavenDBClientSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder used to add services.serviceKeyobjectA unique key that identifies this instance of the RavenDB client service.connectionNamestringThe name used to retrieve the connection string from the "ConnectionStrings" configuration section.configureSettingsAction<RavenDBClientSettings>optionalAn optional delegate that can be used for customizing options. It is invoked after the settings are read from the configuration.Remarks
Notes:
- Reads the configuration from "Aspire:RavenDB:Client" section.
- The
Documents.IDocumentStoreis registered as a singleton, meaning a single instance is shared throughout the application's lifetime, whileSession.IDocumentSessionandSession.IAsyncDocumentSessionare registered per request to ensure short-lived session instances for each use.
AddKeyedRavenDBClient(IHostApplicationBuilder, object, RavenDBClientSettings)Section titled AddKeyedRavenDBClient(IHostApplicationBuilder, object, RavenDBClientSettings)extension Registers
Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client, identified by a unique service key. public static class RavenDBClientExtension{ public static void AddKeyedRavenDBClient( this IHostApplicationBuilder builder, object serviceKey, RavenDBClientSettings settings) { // ... }}Parameters
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder used to add services.serviceKeyobjectA unique key that identifies this instance of the RavenDB client service.settingsRavenDBClientSettingsThe settings required to configure the Documents.IDocumentStore.Remarks
Notes:
- If
RavenDBClientSettings.DatabaseNameis not specified andRavenDBClientSettings.CreateDatabaseis set to 'false',Session.IDocumentSessionandSession.IAsyncDocumentSessionwill not be registered. - The
Documents.IDocumentStoreis registered as a singleton, meaning a single instance is shared throughout the application's lifetime, whileSession.IDocumentSessionandSession.IAsyncDocumentSessionare registered per request to ensure short-lived session instances for each use.
AddRavenDBClient(IHostApplicationBuilder, string, Action<RavenDBClientSettings>)Section titled AddRavenDBClient(IHostApplicationBuilder, string, Action<RavenDBClientSettings>)extension Registers
Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client. public static class RavenDBClientExtension{ public static void AddRavenDBClient( this IHostApplicationBuilder builder, string connectionName, Action<RavenDBClientSettings>? configureSettings = null) { // ... }}Parameters
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder used to add services.connectionNamestringThe name used to retrieve the connection string from the "ConnectionStrings" configuration section.configureSettingsAction<RavenDBClientSettings>optionalAn optional delegate that can be used for customizing options. It is invoked after the settings are read from the configuration.Remarks
Notes:
- Reads the configuration from "Aspire:RavenDB:Client" section.
- The
Documents.IDocumentStoreis registered as a singleton, meaning a single instance is shared throughout the application's lifetime, whileSession.IDocumentSessionandSession.IAsyncDocumentSessionare registered per request to ensure short-lived session instances for each use.
AddRavenDBClient(IHostApplicationBuilder, RavenDBClientSettings)Section titled AddRavenDBClient(IHostApplicationBuilder, RavenDBClientSettings)extension Registers
Documents.IDocumentStore and the associated Session.IDocumentSession and Session.IAsyncDocumentSession instances for connecting to an existing or new RavenDB database with RavenDB.Client. public static class RavenDBClientExtension{ public static void AddRavenDBClient( this IHostApplicationBuilder builder, RavenDBClientSettings settings) { // ... }}Parameters
builderIHostApplicationBuilderThe Hosting.IHostApplicationBuilder used to add services.settingsRavenDBClientSettingsThe settings required to configure the Documents.IDocumentStore.Remarks
Notes:
- If
RavenDBClientSettings.DatabaseNameis not specified andRavenDBClientSettings.CreateDatabaseis set to 'false',Session.IDocumentSessionandSession.IAsyncDocumentSessionwill not be registered. - The
Documents.IDocumentStoreis registered as a singleton, meaning a single instance is shared throughout the application's lifetime, whileSession.IDocumentSessionandSession.IAsyncDocumentSessionare registered per request to ensure short-lived session instances for each use.