/// <summary> /// An asynchronous version of <see cref="Update(string, RecordSet)"/> that calls the respective INSERT, UPDATE, or DELETE statements /// for each added, updated, or deleted row in the specified <see cref="RecordSet"/>. /// </summary> /// <param name="tableName">The name of the source table.</param> /// <param name="recordSet"><see cref="RecordSet"/> to use to update the data source.</param> /// <param name="cancel">The cancellation instruction.</param> /// <returns>The number of rows successfully updated.</returns> public async Task <int> UpdateAsync(string tableName, RecordSet recordSet, CancellationToken cancel) { EnsurePrimaryKey(recordSet); int affected = 0; using (var rsAdapter = new RecordSetAdapter(this, tableName, recordSet)) { affected = await rsAdapter.UpdateAsync(cancel).ConfigureAwait(false); } recordSet.AcceptChanges(); return(affected); }
/// <summary> /// Calls the respective INSERT, UPDATE, or DELETE statements for each inserted, updated, or deleted row in the specified <see cref="RecordSet"/>. /// </summary> /// <param name="tableName">The name of the source table.</param> /// <param name="recordSet"><see cref="RecordSet"/> to use to update the data source.</param> /// <returns>The number of rows successfully updated.</returns> /// <remarks> /// <para><see cref="RecordSet.PrimaryKey"/> should be set before calling <see cref="DbDataAdapter.Update(string, RecordSet)"/>.</para> /// When an application calls the Update method, <see cref="DbDataAdapter"/> examines the <see cref="RecordSet.Row.State"/> property, /// and executes the required INSERT, UPDATE, or DELETE statements iteratively for each row (based on the order of rows in RecordSet). /// </remarks> public int Update(string tableName, RecordSet recordSet) { EnsurePrimaryKey(recordSet); int affected = 0; using (var rsAdapter = new RecordSetAdapter(this, tableName, recordSet)) { affected = rsAdapter.Update(); } recordSet.AcceptChanges(); return(affected); }