RavenDBClientExtension Methods
Class Methods 4 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
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services. serviceKey object A unique key that identifies this instance of the RavenDB client service. connectionName string The name used to retrieve the connection string from the "ConnectionStrings" configuration section. configureSettings Action<RavenDBClientSettings> optional An 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
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services. serviceKey object A unique key that identifies this instance of the RavenDB client service. settings RavenDBClientSettings The 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
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services. connectionName string The name used to retrieve the connection string from the "ConnectionStrings" configuration section. configureSettings Action<RavenDBClientSettings> optional An 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
builder IHostApplicationBuilder The Hosting.IHostApplicationBuilder used to add services. settings RavenDBClientSettings The 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.