Table of Contents

Class AzureCosmosDBServiceBase

Namespace
FoundationaLLM.Context.Services.CosmosDB
Assembly
FoundationaLLM.Context.dll

Provides the base implementation for the Azure Cosmos DB services.

public class AzureCosmosDBServiceBase : IAzureCosmosDBServiceBase
Inheritance
AzureCosmosDBServiceBase
Implements
Inherited Members
Extension Methods

Constructors

AzureCosmosDBServiceBase(IOptions<AzureCosmosDBSettings>, ILogger<AzureCosmosDBServiceBase>)

Initializes a new instance of the AzureCosmosDBServiceBase class.

public AzureCosmosDBServiceBase(IOptions<AzureCosmosDBSettings> options, ILogger<AzureCosmosDBServiceBase> logger)

Parameters

options IOptions<AzureCosmosDBSettings>

The IOptions providing the AzureCosmosDBSettings) with the Azure Cosmos DB settings.

logger ILogger<AzureCosmosDBServiceBase>

The ILogger used for logging.

Fields

_contextContainer

protected readonly Container _contextContainer

Field Value

Container

_cosmosClient

protected readonly CosmosClient _cosmosClient

Field Value

CosmosClient

_logger

protected readonly ILogger<AzureCosmosDBServiceBase> _logger

Field Value

ILogger<AzureCosmosDBServiceBase>

_settings

protected readonly AzureCosmosDBSettings _settings

Field Value

AzureCosmosDBSettings

Properties

ContextContainer

Gets the context container for the Azure Cosmos DB service.

public Container ContextContainer { get; }

Property Value

Container

Methods

RetrieveItems<T>(QueryDefinition)

Retrieves items from Azure Cosmos DB.

public Task<List<T>> RetrieveItems<T>(QueryDefinition query)

Parameters

query QueryDefinition

The query definition used to retrieve the items.

Returns

Task<List<T>>

The list of retrieved items.

Type Parameters

T

The type of item to retrieve.

UpsertItemAsync<T>(string, T, CancellationToken)

Upserts an item in Azure Cosmos DB.

public Task<T> UpsertItemAsync<T>(string partitionKey, T item, CancellationToken cancellationToken = default)

Parameters

partitionKey string

The partition of the item to upsert.

item T

The item to upsert.

cancellationToken CancellationToken

The cancellation token used to signal a cancellation request.

Returns

Task<T>

The upserted item.

Type Parameters

T

The type of the item to upsert.