Class AdoDataConnector
- Namespace
- Datafication.Connectors.AdoConnector
- Assembly
- Datafication.AdoConnector.dll
Represents an ADO data connector which uses ADO.NET infrastructure to connect to a database and retrieve data.
public class AdoDataConnector : IDataConnector
- Inheritance
-
objectAdoDataConnector
- Implements
- Extension Methods
Remarks
This class provides functionalities to connect to a database, execute commands and retrieve data asynchronously.
Constructors
AdoDataConnector(AdoConnectorConfiguration)
Initializes a new instance of the AdoDataConnector class.
public AdoDataConnector(AdoConnectorConfiguration configuration)
Parameters
configurationAdoConnectorConfigurationThe configuration for the ADO data connector.
Exceptions
- ArgumentNullException
Thrown when the provided configuration is null.
- ArgumentException
Thrown when the configuration validation fails.
Properties
Configuration
Gets the configuration for the ADO data connector.
public AdoConnectorConfiguration Configuration { get; }
Property Value
Methods
GetConnectorId()
Gets the connector's unique identifier.
public string GetConnectorId()
Returns
- string
The unique identifier of the connector.
GetDataAsync()
Asynchronously retrieves data from the database using the configured provider and connection string.
public Task<DataBlock> GetDataAsync()
Returns
- Task<DataBlock>
A task that represents the asynchronous operation. The task result contains a DataBlock with the query results.
Remarks
This method automatically creates a database connection, executes the configured command, and converts the results into a DataBlock. The connection is automatically managed and disposed.
Exceptions
- Exception
Thrown when there is an error executing the database command or when the configuration is invalid.
GetStorageDataAsync(IStorageDataBlock, int)
Asynchronously retrieves data from the database and appends it in batches to the provided storage data block.
public Task<IStorageDataBlock> GetStorageDataAsync(IStorageDataBlock target, int batchSize = 10000)
Parameters
targetIStorageDataBlockThe storage data block to append batches to.
batchSizeintThe maximum number of rows to accumulate before appending a batch. Defaults to 10000.
Returns
- Task<IStorageDataBlock>
A task that represents the asynchronous operation. The task result contains the provided IStorageDataBlock with all data appended.
Remarks
This method automatically creates a database connection, executes the configured command, and streams data in batches to the provided storage block. The connection is automatically managed and disposed.
Exceptions
- ArgumentNullException
Thrown when target is null.
- Exception
Thrown when there is an error executing the database command or when the configuration is invalid.