Class AdoDataProvider
- Namespace
- combit.Reporting.DataProviders
- Assembly
- combit.ListLabel31.CrossPlatform.dll
Represents an ADO.NET data provider that wraps ADO.NET objects and exposes them as an IDataProvider.
public sealed class AdoDataProvider : IDataProvider, IDisposable, ICanHandleUsedIdentifiers
- Inheritance
-
AdoDataProvider
- Implements
- Inherited Members
Examples
The following example demonstrates how to use the AdoDataProvider to export a report to PDF:
// Example 1: Using a DataSet with multiple tables and relations
DataSet dataSet = new DataSet();
// Load data from database or other source
using (SqlConnection connection = new SqlConnection(connectionString))
{
SqlDataAdapter customersAdapter = new SqlDataAdapter("SELECT * FROM Customers", connection);
customersAdapter.Fill(dataSet, "Customers");
SqlDataAdapter ordersAdapter = new SqlDataAdapter("SELECT * FROM Orders", connection);
ordersAdapter.Fill(dataSet, "Orders");
}
// Define relationships between tables
dataSet.Relations.Add("CustomerOrders",
dataSet.Tables["Customers"].Columns["CustomerID"],
dataSet.Tables["Orders"].Columns["CustomerID"]);
// Create the AdoDataProvider
AdoDataProvider provider = new AdoDataProvider(dataSet);
// Create a ListLabel reporting engine instance and assign the provider as the data source.
using ListLabel listLabel = new ListLabel();
listLabel.DataSource = provider;
// Configure export settings to generate a PDF.
ExportConfiguration exportConfiguration = new ExportConfiguration(LlExportTarget.Pdf, exportFilePath, projectFilePath);
exportConfiguration.ShowResult = true;
// Export the report to PDF.
listLabel.Export(exportConfiguration);
// Example 2: Using a single DataTable
DataTable customersTable = new DataTable("Customers");
// ... populate table ...
AdoDataProvider singleTableProvider = new AdoDataProvider(customersTable);
// Example 3: Using a filtered DataView
DataView filteredView = new DataView(customersTable);
filteredView.RowFilter = "Country = 'USA'";
filteredView.Sort = "CustomerName ASC";
AdoDataProvider viewProvider = new AdoDataProvider(filteredView);
Remarks
The AdoDataProvider class provides a bridge between ADO.NET data structures (such as DataSet, DataTable, DataView, and DataViewManager) and the List & Label reporting engine. It automatically wraps ADO.NET objects to provide a consistent interface for data binding, supporting features like filtering, sorting, and table relationships defined in the underlying ADO.NET objects. The provider implements ICanHandleUsedIdentifiers to optimize data retrieval by loading only the columns actually used in the report. When initialized with a DataSet or DataViewManager, it automatically discovers and exposes all tables and their relationships. For single-table scenarios, DataTable or DataView can be used. The provider supports advanced filtering using DataView row filter expressions, including functions like IIF, SUBSTRING, and aggregate operations.
Constructors
AdoDataProvider(DataSet)
Initializes a new instance of the AdoDataProvider class using the specified DataSet.
public AdoDataProvider(DataSet dataSet)
Parameters
AdoDataProvider(DataTable)
Initializes a new instance of the AdoDataProvider class using the specified DataTable.
public AdoDataProvider(DataTable dataTable)
Parameters
AdoDataProvider(DataView)
Initializes a new instance of the AdoDataProvider class using the specified DataView.
public AdoDataProvider(DataView dataView)
Parameters
AdoDataProvider(DataViewManager)
Initializes a new instance of the AdoDataProvider class using the specified DataViewManager.
public AdoDataProvider(DataViewManager dataViewManager)
Parameters
dataViewManagerDataViewManagerThe DataViewManager to be used by the data provider.
Methods
Dispose()
Releases all resources used by the current instance of the AdoDataProvider class.
public void Dispose()
~AdoDataProvider()
Finalizes an instance of the AdoDataProvider class.
protected ~AdoDataProvider()