SaveBatchOnlyAsync
Part of the QSAppContext object. Commits only the operations that were queued under a specific BatchId – without affecting any changes made to the screen model (Qss). This gives you fine‑grained control over batch execution when you want to persist a group of inserts, updates, or deletes independently.
While SaveChangesAsync flushes all Qss model modifications, this method targets exactly one batch queue. If you have multiple batches, only the one identified by BatchId is executed, and its sql statements are sent to the database.
Signature
public async Task<int> SaveBatchOnlyAsync(Guid BatchId)Parameters
| Name | Type | Description |
|---|---|---|
BatchId | Guid | The unique identifier of the batch to be saved. This is the same BatchId used when queuing operations via methods like AddRecordByDictionaryAsync or DeleteRecordByIdAsync. |
Returns
A Task<int> representing the asynchronous operation. The integer result is the number of rows affected by the batch (inserted, updated, or deleted). If the batch was empty or contained only operations that failed, the return value may be 0 or reflect the successful rows.
Example Usage
// Prepare a batch for a few operations
Guid batchId = Guid.NewGuid();
IQSDataTable orders = QSAppContext.Tables["Orders"];
// Queue a new record and a deletion
var newOrder = new Dictionary<string, object?> { {"OrderId", "ORD-100"}, {"Amount", 250} };
await orders.AddRecordByDictionaryAsync(newOrder, batchId);
await orders.DeleteRecordByIdAsync("ORD-050", batchId);
// Now save only this batch — no other pending changes are touched
int rowsAffected = await QSAppContext.SaveBatchOnlyAsync(batchId);
Console.WriteLine($"Batch {batchId} saved: {rowsAffected} rows");