SaveBatchAndQssAsync

Part of the QSAppContext object. Saves both the pending screen model changes (the Qss object) and a specific queued batch of operations in a single call. If any Qss modifications exist, they are committed first, followed by the execution of the batch identified by BatchId.

This gives a convenient “save everything” behaviour for a data‑entry scenario where the user has edited fields on screen and code has also queued additional inserts, updates, or deletes under a common batch identifier.

Signature

public async Task<int> SaveBatchAndQssAsync(Guid BatchId)

Parameters

NameTypeDescription
BatchIdGuid The unique identifier of the batch to be saved. The same BatchId used when queuing operations via methods like AddRecordByDictionaryAsync or DeleteRecordByIdAsync.

Returns

A Task<int> representing the asynchronous operation. The integer is the total number of rows affected by the overall save – it includes rows from the Qss model changes (if any) and the rows affected by the batch execution. A return value of 0 means no changes were found to persist.

Example Usage

// User has edited screen fields
Qss["NameAr"] = "مؤسسة النجاح";
Qss["Email"] = "contact@domain.com";

// Code also queues a batch of related operations
Guid batchId = Guid.NewGuid();
IQSDataTable contacts = QSAppContext.Tables["Contacts"];
await contacts.AddRecordByDictionaryAsync(
    new Dictionary<string, object?> { {"Id", "CNT-001"}, {"Name", "Support"} },
    batchId
);

// Save everything – screen changes + the batch
int totalRows = await QSAppContext.SaveBatchAndQssAsync(batchId);
Console.WriteLine($"Total affected rows: {totalRows}");