BulkOperationExecutor
- Namespace:
PPDS.Dataverse.BulkOperations - Assembly:
PPDS.Dataverse - Kind: Class
- Implements:
IBulkOperationExecutor
Summary
Executes bulk operations using modern Dataverse APIs. Uses CreateMultipleRequest, UpdateMultipleRequest, UpsertMultipleRequest for optimal performance.
Members
Constructors
BulkOperationExecutor(IDataverseConnectionPool connectionPool, IThrottleTracker throttleTracker, IOptions<DataverseOptions> options, ILogger<BulkOperationExecutor> logger)
BulkOperationExecutor(IDataverseConnectionPool connectionPool, IThrottleTracker throttleTracker, IOptions<DataverseOptions> options, ILogger<BulkOperationExecutor> logger)
Initializes a new instance of the PPDS.Dataverse.BulkOperations.BulkOperationExecutor class.
-
Param
connectionPool: The connection pool. -
Param
throttleTracker: The throttle tracker for pre-flight throttle checks. -
Param
options: Configuration options. -
Param
logger: Logger instance.
Methods
AnalyzeBatchFailure
IReadOnlyList<BatchFailureDiagnostic> AnalyzeBatchFailure(IReadOnlyList<Entity> batch, Exception exception)
Analyzes a batch failure to identify which record(s) caused the failure.
-
Param
batch: The batch of entities that failed. -
Param
exception: The exception that was thrown. -
Returns: A list of diagnostics identifying problematic records.
CreateMultipleAsync
Task<BulkOperationResult> CreateMultipleAsync(string entityLogicalName, IEnumerable<Entity> entities, BulkOperationOptions options, DataverseClientOptions clientOptions, IProgress<ProgressSnapshot> progress, CancellationToken cancellationToken)
Creates multiple records using the CreateMultiple API.
-
Param
entityLogicalName: The entity logical name. -
Param
entities: The entities to create. -
Param
options: Bulk operation options. -
Param
clientOptions: Optional per-request connection options (e.g., CallerId for impersonation). -
Param
progress: Optional progress reporter for tracking operation progress. -
Param
cancellationToken: Cancellation token. -
Returns: The result of the operation.
DeleteMultipleAsync
Task<BulkOperationResult> DeleteMultipleAsync(string entityLogicalName, IEnumerable<Guid> ids, BulkOperationOptions options, DataverseClientOptions clientOptions, IProgress<ProgressSnapshot> progress, CancellationToken cancellationToken)
Deletes multiple records using the DeleteMultiple API.
-
Param
entityLogicalName: The entity logical name. -
Param
ids: The IDs of the records to delete. -
Param
options: Bulk operation options. -
Param
clientOptions: Optional per-request connection options (e.g., CallerId for impersonation). -
Param
progress: Optional progress reporter for tracking operation progress. -
Param
cancellationToken: Cancellation token. -
Returns: The result of the operation.
UpdateMultipleAsync
Task<BulkOperationResult> UpdateMultipleAsync(string entityLogicalName, IEnumerable<Entity> entities, BulkOperationOptions options, DataverseClientOptions clientOptions, IProgress<ProgressSnapshot> progress, CancellationToken cancellationToken)
Updates multiple records using the UpdateMultiple API.
-
Param
entityLogicalName: The entity logical name. -
Param
entities: The entities to update. -
Param
options: Bulk operation options. -
Param
clientOptions: Optional per-request connection options (e.g., CallerId for impersonation). -
Param
progress: Optional progress reporter for tracking operation progress. -
Param
cancellationToken: Cancellation token. -
Returns: The result of the operation.
UpsertMultipleAsync
Task<BulkOperationResult> UpsertMultipleAsync(string entityLogicalName, IEnumerable<Entity> entities, BulkOperationOptions options, DataverseClientOptions clientOptions, IProgress<ProgressSnapshot> progress, CancellationToken cancellationToken)
Upserts multiple records using the UpsertMultiple API.
-
Param
entityLogicalName: The entity logical name. -
Param
entities: The entities to upsert. -
Param
options: Bulk operation options. -
Param
clientOptions: Optional per-request connection options (e.g., CallerId for impersonation). -
Param
progress: Optional progress reporter for tracking operation progress. -
Param
cancellationToken: Cancellation token. -
Returns: The result of the operation.
Properties
AdaptiveSizer
AdaptiveBatchSizer AdaptiveSizer { get; set; }
Gets or sets an optional adaptive batch sizer that dynamically adjusts batch sizes
based on observed execution times. When null, the fixed PPDS.Dataverse.BulkOperations.BulkOperationOptions.BatchSize
is used for all batches.
ThrottleManager
AdaptiveThrottleManager ThrottleManager { get; set; }
Gets or sets an optional adaptive throttle manager that dynamically adjusts the
degree of parallelism based on 429 (service protection limit) responses.
When null, throttle events are handled by the existing retry logic without
adjusting parallelism. Complementary to PPDS.Dataverse.BulkOperations.BulkOperationExecutor.AdaptiveSizer: that adjusts
batch SIZE, this adjusts thread COUNT.