Class CosmosDbDataProvider<T>
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.CosmosDBDataProvider.dll
Provides a data provider implementation for Azure Cosmos DB by wrapping queried items in an ObjectDataProvider.
public sealed class CosmosDbDataProvider<T> : IDataProvider, ISupportsLogger
Type Parameters
T
- Inheritance
-
CosmosDbDataProvider<T>
- Implements
- Inherited Members
Examples
The following example demonstrates how to query Cosmos DB using the CosmosDbDataProvider<T> and export the resulting report to PDF:
// Create a CosmosDbDataProvider for a specific keyspace.
CosmosDbDataProvider<MyItemType> provider = new CosmosDbDataProvider<MyItemType>(
"https://your-cosmosdb-uri",
"your-access-token",
"your-database",
"your-container",
"SELECT * FROM c");
// Create and configure the List & Label reporting engine.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, @"C:\Exports\report.pdf", @"C:\Projects\report.llproj");
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
Remarks
The CosmosDbDataProvider<T> class connects to a Cosmos DB instance using the provided URI and token, queries the specified database and container using a SQL query, and internally wraps the returned items in an ObjectDataProvider.
Constructors
CosmosDbDataProvider(string, string, string, string, string)
Initializes a new instance of the CosmosDbDataProvider<T> class.
public CosmosDbDataProvider(string uri, string token, string database, string container, string sqlQuery = null)
Parameters
uristringThe URI of the Cosmos DB account.
tokenstringThe access token for the Cosmos DB account.
databasestringThe name of the database to query.
containerstringThe name of the container to query.
sqlQuerystringAn optional SQL query to execute. If not provided, the default query "SELECT * FROM c" is used.
Exceptions
- CosmosException
Thrown when an error occurs during the query execution.