Show / Hide Table of Contents

Class CosmosClientOptionsUtilities

Inheritance
object
CosmosClientOptionsUtilities
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: Benday.CosmosDb.Utilities
Assembly: Benday.CosmosDb.dll
Syntax
public static class CosmosClientOptionsUtilities

Methods

| Edit this page View Source

ConfigureCosmosClient(IServiceCollection, CosmosConfig)

Configures a CosmosClient instance in the service collection using a CosmosConfig object.

Declaration
public static void ConfigureCosmosClient(this IServiceCollection services, CosmosConfig cosmosConfig)
Parameters
Type Name Description
IServiceCollection services
CosmosConfig cosmosConfig
| Edit this page View Source

ConfigureCosmosClient(IServiceCollection, string, bool, bool, JsonNamingPolicy?)

Configures a CosmosClient instance in the service collection.

Declaration
public static void ConfigureCosmosClient(this IServiceCollection services, string connectionString, bool useGatewayMode = false, bool allowBulkExecution = true, JsonNamingPolicy? jsonNamingPolicy = null)
Parameters
Type Name Description
IServiceCollection services
string connectionString
bool useGatewayMode
bool allowBulkExecution
JsonNamingPolicy jsonNamingPolicy
| Edit this page View Source

ConfigureParentedRepository<TEntity>(IServiceCollection, string, string, string, string, bool, bool, bool)

Configures a repository for a specific parented item entity type using default implementation of CosmosDbParentedItemRepository.

Declaration
public static void ConfigureParentedRepository<TEntity>(this IServiceCollection services, string connectionString, string databaseName, string containerName, string partitionKey, bool createStructures, bool useHierarchicalPartitionKey, bool useDefaultAzureCredential = false) where TEntity : ParentedItemBase, new()
Parameters
Type Name Description
IServiceCollection services

Service collection

string connectionString

Connection string or endpoint for Cosmos DB

string databaseName

Database name

string containerName

Container name

string partitionKey

Partition key

bool createStructures

Create structures as part of the instantiation of this repository class (NOTE: this should probably be false in production)

bool useHierarchicalPartitionKey

Use hierarchical partition key

bool useDefaultAzureCredential

Use DefaultAzureCredential for authentication

Type Parameters
Name Description
TEntity

Entity type that inherits from ParentedItemBase

| Edit this page View Source

ConfigureParentedRepository<TEntity, TInterface, TImplementation>(IServiceCollection, string, string, string, string, bool, bool, bool)

Configures a repository for a specific parented item entity type using a custom implementation of the repository.

Declaration
public static void ConfigureParentedRepository<TEntity, TInterface, TImplementation>(this IServiceCollection services, string connectionString, string databaseName, string containerName, string partitionKey, bool createStructures, bool useHierarchicalPartitionKey, bool useDefaultAzureCredential = false) where TInterface : class where TImplementation : class, TInterface
Parameters
Type Name Description
IServiceCollection services

Service collection

string connectionString

Connection string or endpoint for Cosmos DB

string databaseName

Database name

string containerName

Container name

string partitionKey

Partition key

bool createStructures

Create structures as part of the instantiation of this repository class (NOTE: this should probably be false in production)

bool useHierarchicalPartitionKey

Use hierarchical partition key

bool useDefaultAzureCredential

Use DefaultAzureCredential for authentication

Type Parameters
Name Description
TEntity

Entity type that inherits from ParentedItemBase

TInterface

Repository interface

TImplementation

Repository implementation

| Edit this page View Source

ConfigureRepository<TEntity>(IServiceCollection, string, string, string, string, bool, bool, bool)

Configures a repository for a specific domain model entity type using default implementation of CosmosTenantItemRepository.

Declaration
public static void ConfigureRepository<TEntity>(this IServiceCollection services, string connectionString, string databaseName, string containerName, string partitionKey, bool createStructures, bool useHierarchicalPartitionKey, bool useDefaultAzureCredential = false) where TEntity : TenantItemBase, new()
Parameters
Type Name Description
IServiceCollection services

Services collection

string connectionString

Connection string for cosmos db

string databaseName

Database name

string containerName

Container name

string partitionKey

Partition key definition string

bool createStructures

Create structures as part of the instantiation of this repository class (NOTE: this should probably be false in production)

bool useHierarchicalPartitionKey

Use hierarchical partition key

bool useDefaultAzureCredential
Type Parameters
Name Description
TEntity
| Edit this page View Source

ConfigureRepository<TEntity, TInterface, TImplementation>(IServiceCollection, string, string, string, string, bool, bool, bool)

Configures a repository for a specific domain model entity type using a custom implementation of the repository.

Declaration
public static void ConfigureRepository<TEntity, TInterface, TImplementation>(this IServiceCollection services, string connectionString, string databaseName, string containerName, string partitionKey, bool createStructures, bool useHierarchicalPartitionKey, bool useDefaultAzureCredential = false) where TInterface : class where TImplementation : class, TInterface
Parameters
Type Name Description
IServiceCollection services
string connectionString
string databaseName
string containerName
string partitionKey
bool createStructures
bool useHierarchicalPartitionKey
bool useDefaultAzureCredential
Type Parameters
Name Description
TEntity
TInterface
TImplementation
| Edit this page View Source

GetCosmosConfig(IConfiguration)

Gets a CosmosConfig object from the configuration.

Declaration
public static CosmosConfig GetCosmosConfig(this IConfiguration configuration)
Parameters
Type Name Description
IConfiguration configuration
Returns
Type Description
CosmosConfig
Exceptions
Type Condition
InvalidOperationException
| Edit this page View Source

GetCosmosDbClientOptions()

Gets the default CosmosClientOptions for a Cosmos DB client that uses System.Text.Json. This version of the method uses the default JsonNamingPolicy for the JsonSerializerOptions

Declaration
public static CosmosClientOptions GetCosmosDbClientOptions()
Returns
Type Description
CosmosClientOptions

Client options object

| Edit this page View Source

GetCosmosDbClientOptions(JsonNamingPolicy?, ConnectionMode, bool)

Gets the default CosmosClientOptions for a Cosmos DB client that uses System.Text.Json and provides an option to customize the JsonNamingPolicy for the JsonSerializerOptions.

Declaration
public static CosmosClientOptions GetCosmosDbClientOptions(JsonNamingPolicy? jsonNamingPolicy, ConnectionMode connectionMode = ConnectionMode.Gateway, bool allowBulkExecution = true)
Parameters
Type Name Description
JsonNamingPolicy jsonNamingPolicy

Naming policy or null to not use a policy

ConnectionMode connectionMode

Connection mode

bool allowBulkExecution

Allow bulk execution. Default value is true.

Returns
Type Description
CosmosClientOptions
Remarks

This method creates a new instance of CosmosClientOptions with the specified settings.

| Edit this page View Source

RegisterOptionsForRepository<T>(IServiceCollection, string, string, string, string, bool, bool, bool)

Registers options for a repository.

Declaration
public static void RegisterOptionsForRepository<T>(this IServiceCollection services, string connectionString, string databaseName, string containerName, string partitionKey, bool createStructures, bool useHierarchicalPartitionKey, bool useDefaultAzureCredential)
Parameters
Type Name Description
IServiceCollection services
string connectionString
string databaseName
string containerName
string partitionKey
bool createStructures
bool useHierarchicalPartitionKey
bool useDefaultAzureCredential
Type Parameters
Name Description
T
| Edit this page View Source

ThrowIfEmptyOrNull(string?, string?)

Declaration
public static string ThrowIfEmptyOrNull(this string? value, string? valueName = null)
Parameters
Type Name Description
string value
string valueName
Returns
Type Description
string
  • Edit this page
  • View Source
In this article
Back to top Copyright © www.benday.com | info@benday.com