diff --git a/RepoDb.Core/RepoDb/Extensions/DbConnectionExtension.cs b/RepoDb.Core/RepoDb/Extensions/DbConnectionExtension.cs index 4516d5028..711ba6b01 100644 --- a/RepoDb.Core/RepoDb/Extensions/DbConnectionExtension.cs +++ b/RepoDb.Core/RepoDb/Extensions/DbConnectionExtension.cs @@ -82,8 +82,6 @@ public static IDbConnection EnsureOpen(this IDbConnection connection) return connection; } - // TODO: Ensure that the cancellation token is passed from the caller - /// /// Ensures the connection object is open in an asynchronous way. /// @@ -319,6 +317,7 @@ internal static async Task> ExecuteQueryAsyncInternal(this commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: null, dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck)) @@ -836,6 +835,7 @@ private static async Task> ExecuteQueryAsyncInternalForType commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: typeof(TResult), dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck)) @@ -1096,6 +1096,7 @@ internal static async Task ExecuteReaderAsyncInternal(this IDbConne commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: entityType, dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck); @@ -1263,6 +1264,7 @@ internal static async Task ExecuteNonQueryAsyncInternal(this IDbConnection commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: entityType, dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck)) @@ -1414,6 +1416,7 @@ internal static async Task ExecuteScalarAsyncInternal(this IDbConnection commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: entityType, dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck)) @@ -1569,6 +1572,7 @@ internal static async Task ExecuteScalarAsyncInternal(this IDb commandType: commandType, commandTimeout: commandTimeout, transaction: transaction, + cancellationToken: cancellationToken, entityType: entityType, dbFields: dbFields, skipCommandArrayParametersCheck: skipCommandArrayParametersCheck)) @@ -1705,11 +1709,13 @@ internal static ClassProperty GetAndGuardPrimaryKeyOrIdentityKey(IDbCon /// /// /// + /// /// internal static Task GetAndGuardPrimaryKeyOrIdentityKeyAsync(IDbConnection connection, - IDbTransaction transaction) + IDbTransaction transaction, + CancellationToken cancellation = default) where TEntity : class => - GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, ClassMappedNameCache.Get(), transaction); + GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, ClassMappedNameCache.Get(), transaction, cancellation); /// /// @@ -1718,16 +1724,18 @@ internal static Task GetAndGuardPrimaryKeyOrIdentityKeyAsync /// /// + /// /// internal static async Task GetAndGuardPrimaryKeyOrIdentityKeyAsync(IDbConnection connection, string tableName, - IDbTransaction transaction) + IDbTransaction transaction, + CancellationToken cancellationToken = default) where TEntity : class { var property = PrimaryCache.Get() ?? IdentityCache.Get(); if (property == null) { - var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction); + var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken); property = GetAndGuardPrimaryKeyOrIdentityKey(dbFields); } return GetAndGuardPrimaryKeyOrIdentityKey(tableName, property); @@ -1791,12 +1799,14 @@ internal static DbField GetAndGuardPrimaryKeyOrIdentityKey(IDbConnection connect /// /// /// + /// /// internal static async Task GetAndGuardPrimaryKeyOrIdentityKeyAsync(IDbConnection connection, string tableName, - IDbTransaction transaction) + IDbTransaction transaction, + CancellationToken cancellationToken = default) { - var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction); + var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken); var dbField = dbFields?.FirstOrDefault(df => df.IsPrimary == true) ?? dbFields?.FirstOrDefault(df => df.IsIdentity == true); return GetAndGuardPrimaryKeyOrIdentityKey(tableName, dbField); } @@ -1856,11 +1866,13 @@ internal static QueryGroup WhatToQueryGroup(this IDbConnection connection, /// /// /// + /// /// internal static async Task WhatToQueryGroupAsync(this IDbConnection connection, string tableName, T what, - IDbTransaction transaction) + IDbTransaction transaction, + CancellationToken cancellationToken = default) { if (what == null) { @@ -1869,7 +1881,7 @@ internal static async Task WhatToQueryGroupAsync(this IDbConnecti var queryGroup = WhatToQueryGroup(what); if (queryGroup == null) { - var dbField = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var dbField = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); queryGroup = WhatToQueryGroup(dbField, what); } return queryGroup; @@ -1931,10 +1943,12 @@ internal static QueryGroup WhatToQueryGroup(IDbConnection connection, /// /// /// + /// /// internal static async Task WhatToQueryGroupAsync(IDbConnection connection, object what, - IDbTransaction transaction) + IDbTransaction transaction, + CancellationToken cancellationToken = default) where TEntity : class { if (what == null) @@ -1946,7 +1960,7 @@ internal static async Task WhatToQueryGroupAsync(IDbConnect { return queryGroup; } - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, ClassMappedNameCache.Get(), transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, ClassMappedNameCache.Get(), transaction, cancellationToken); return WhatToQueryGroup(key, what); } @@ -2365,6 +2379,7 @@ internal static DbCommand CreateDbCommandForExecution(this IDbConnection connect /// /// /// + /// /// /// /// @@ -2375,6 +2390,7 @@ internal static async Task CreateDbCommandForExecutionAsync(this IDbC CommandType? commandType = null, int? commandTimeout = null, IDbTransaction transaction = null, + CancellationToken cancellationToken = default, Type entityType = null, IEnumerable dbFields = null, bool skipCommandArrayParametersCheck = true) @@ -2383,7 +2399,7 @@ internal static async Task CreateDbCommandForExecutionAsync(this IDbC ValidateTransactionConnectionObject(connection, transaction); // Open - await connection.EnsureOpenAsync(); + await connection.EnsureOpenAsync(cancellationToken); // Call return CreateDbCommandForExecutionInternal(connection: connection, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/BatchQuery.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/BatchQuery.cs index 4a4a4ebb0..8431ea47d 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/BatchQuery.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/BatchQuery.cs @@ -1191,7 +1191,7 @@ internal static async Task> BatchQueryAsyncInternal(fields) ?? - (await DbFieldCache.GetAsync(connection, tableName, transaction))?.AsFields(); + (await DbFieldCache.GetAsync(connection, tableName, transaction, true, cancellationToken))?.AsFields(); // Return return await BatchQueryAsyncInternalBase(connection: connection, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Delete.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Delete.cs index 05c8101f6..f265e10f5 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Delete.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Delete.cs @@ -302,7 +302,7 @@ public static async Task DeleteAsync(this IDbConnection connection CancellationToken cancellationToken = default) where TEntity : class { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction, cancellationToken); return await DeleteAsyncInternal(connection: connection, where: ToQueryGroup(key, entity), hints: hints, @@ -338,7 +338,7 @@ public static async Task DeleteAsync(this IDbConnection con where TEntity : class { return await DeleteAsyncInternal(connection: connection, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -371,7 +371,7 @@ public static async Task DeleteAsync(this IDbConnection connection where TEntity : class { return await DeleteAsyncInternal(connection: connection, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -795,7 +795,7 @@ public static async Task DeleteAsync(this IDbConnection connection, { return await DeleteAsyncInternal(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -829,7 +829,7 @@ public static async Task DeleteAsync(this IDbConnection connection, { return await DeleteAsyncInternal(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/DeleteAll.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/DeleteAll.cs index 1f65a94d8..f10b9dd99 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/DeleteAll.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/DeleteAll.cs @@ -317,7 +317,7 @@ public static async Task DeleteAllAsync(this IDbConnection connect CancellationToken cancellationToken = default) where TEntity : class { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction, cancellationToken); var keys = ExtractPropertyValues(entities, key).AsList(); return await DeleteAllAsyncInternal(connection: connection, @@ -405,7 +405,7 @@ public static async Task DeleteAllAsync(this IDbConnection connect } /// - /// Delete all the rows from the table in an asynchronous way. It uses the operation as the underlying operation. + /// Delete all the rows from the table in an asynchronous way. /// /// The type of the data entity. /// The connection object to be used. @@ -427,7 +427,7 @@ public static async Task DeleteAllAsync(this IDbConnection connect CancellationToken cancellationToken = default) where TEntity : class { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction, cancellationToken); var keys = ExtractPropertyValues(entities, key)?.AsList(); return await DeleteAllAsyncInternal(connection: connection, @@ -442,7 +442,7 @@ public static async Task DeleteAllAsync(this IDbConnection connect } /// - /// Delete all the rows from the table in an asynchronous way. It uses the operation as the underlying operation. + /// Delete all the rows from the table in an asynchronous way. /// /// The type of the data entity. /// The type of the key column. @@ -477,7 +477,7 @@ public static Task DeleteAllAsync(this IDbConnection connect } /// - /// Delete all the rows from the table in an asynchronous way. It uses the operation as the underlying operation. + /// Delete all the rows from the table in an asynchronous way. /// /// The type of the data entity. /// The connection object to be used. @@ -881,7 +881,7 @@ public static async Task DeleteAllAsyncInternal(this IDbConnection connecti IStatementBuilder statementBuilder = null, CancellationToken cancellationToken = default) { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); var dbSetting = connection.GetDbSetting(); var hasImplicitTransaction = false; var count = keys?.AsList()?.Count; @@ -892,7 +892,7 @@ public static async Task DeleteAllAsyncInternal(this IDbConnection connecti // Creates a transaction (if needed) if (transaction == null && count > ParameterBatchCount) { - transaction = (await connection.EnsureOpenAsync()).BeginTransaction(); + transaction = (await connection.EnsureOpenAsync(cancellationToken)).BeginTransaction(); hasImplicitTransaction = true; } diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Exists.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Exists.cs index 001da32a9..f1184be22 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Exists.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Exists.cs @@ -272,7 +272,7 @@ public static async Task ExistsAsync(this IDbConnection connectio where TEntity : class { return await ExistsAsyncInternal(connection: connection, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -306,7 +306,7 @@ public static async Task ExistsAsync(this IDbConnection co where TEntity : class { return await ExistsAsyncInternal(connection: connection, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -730,7 +730,7 @@ public static async Task ExistsAsync(this IDbConnection connection, { return await ExistsAsyncInternal(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, @@ -764,7 +764,7 @@ public static async Task ExistsAsync(this IDbConnection connection, { return await ExistsAsyncInternal(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), hints: hints, commandTimeout: commandTimeout, transaction: transaction, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Insert.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Insert.cs index cadc4b070..cc63b34e8 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Insert.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Insert.cs @@ -683,7 +683,7 @@ internal async static Task InsertAsyncInternalBase(th var dbSetting = connection.GetDbSetting(); // Get the database fields - var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction); + var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken); // Get the context var context = await InsertExecutionContextProvider.CreateAsync(connection, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Merge.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Merge.cs index 4d53026d7..f1d32574c 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Merge.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Merge.cs @@ -2177,7 +2177,7 @@ internal static async Task MergeAsyncInternalBase(thi // Check the qualifiers if (qualifiers?.Any() != true) { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); qualifiers = key.AsField().AsEnumerable(); } @@ -2280,7 +2280,7 @@ internal static async Task UpsertAsyncInternalBase(th { // Variables needed var type = entity?.GetType() ?? typeof(TEntity); - var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction); + var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken); var primary = dbFields?.FirstOrDefault(dbField => dbField.IsPrimary); var properties = (IEnumerable)null; var primaryKey = (ClassProperty)null; diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/MergeAll.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/MergeAll.cs index 2e9d3162d..0d025bede 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/MergeAll.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/MergeAll.cs @@ -800,7 +800,7 @@ internal static async Task MergeAllAsyncInternal(this IDbConnectio // Check the qualifiers if (qualifiers?.Any() != true) { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); qualifiers = key.AsField().AsEnumerable(); } @@ -1676,7 +1676,7 @@ internal static async Task MergeAllAsyncInternalBase(this IDbConne var index = 0; do { - if (await reader.ReadAsync()) + if (await reader.ReadAsync(cancellationToken)) { var value = Converter.DbNullToNull(reader.GetValue(0)); context.IdentityPropertySetterFunc.Invoke(batchItems[index], value); @@ -1762,7 +1762,7 @@ internal static async Task UpsertAllAsyncInternalBase(this IDbConn // Variables needed var type = entities?.First()?.GetType() ?? typeof(TEntity); var isObjectType = typeof(TEntity) == StaticType.Object; - var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction); + var dbFields = await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken); var primary = dbFields?.FirstOrDefault(dbField => dbField.IsPrimary); var properties = (IEnumerable)null; var primaryKey = (ClassProperty)null; diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Query.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Query.cs index 2dce7d43d..aa135e483 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Query.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Query.cs @@ -761,7 +761,7 @@ public static async Task> QueryAsync(this IDbConne return await QueryAsyncInternal(connection: connection, tableName: tableName, fields: fields, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), orderBy: orderBy, top: top, hints: hints, @@ -819,7 +819,7 @@ public static async Task> QueryAsync(this I return await QueryAsyncInternal(connection: connection, tableName: tableName, fields: fields, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), orderBy: orderBy, top: top, hints: hints, @@ -1101,7 +1101,7 @@ public static async Task> QueryAsync(this IDbConne { return await QueryAsyncInternal(connection: connection, tableName: ClassMappedNameCache.Get(), - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), fields: fields, orderBy: orderBy, top: top, @@ -1157,7 +1157,7 @@ public static async Task> QueryAsync(this I { return await QueryAsyncInternal(connection: connection, tableName: ClassMappedNameCache.Get(), - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), fields: fields, orderBy: orderBy, top: top, @@ -1434,7 +1434,7 @@ internal static async Task> QueryAsyncInternal(thi { // Ensure the fields fields = GetQualifiedFields(fields) ?? - (await DbFieldCache.GetAsync(connection, tableName, transaction))?.AsFields(); + (await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken))?.AsFields(); // Return return await QueryAsyncInternalBase(connection: connection, @@ -1816,7 +1816,7 @@ public static async Task> QueryAsync(this IDbConnect { return await QueryAsync(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), fields: fields, orderBy: orderBy, top: top, @@ -1871,7 +1871,7 @@ public static async Task> QueryAsync(this IDbConnection con { return await QueryAsync(connection: connection, tableName: tableName, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), fields: fields, orderBy: orderBy, top: top, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/QueryAll.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/QueryAll.cs index e535123c4..e65207a6b 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/QueryAll.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/QueryAll.cs @@ -306,7 +306,7 @@ internal static async Task> QueryAllAsyncInternal( { // Ensure the fields fields = GetQualifiedFields(fields) ?? - (await DbFieldCache.GetAsync(connection, tableName, transaction))?.AsFields(); + (await DbFieldCache.GetAsync(connection, tableName, transaction, cancellationToken))?.AsFields(); // Return return await QueryAllAsyncInternalBase(connection: connection, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/Update.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/Update.cs index 13323b798..c9d4ee67d 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/Update.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/Update.cs @@ -622,7 +622,7 @@ public static async Task UpdateAsync(this IDbConnection connection CancellationToken cancellationToken = default) where TEntity : class { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); return await UpdateAsyncInternal(connection: connection, tableName: tableName, entity: entity, @@ -669,7 +669,7 @@ public static async Task UpdateAsync(this IDbConnection con return await UpdateAsyncInternal(connection: connection, tableName: tableName, entity: entity, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), fields: fields, hints: hints, commandTimeout: commandTimeout, @@ -711,7 +711,7 @@ public static async Task UpdateAsync(this IDbConnection connection return await UpdateAsyncInternal(connection: connection, tableName: tableName, entity: entity, - where: await WhatToQueryGroupAsync(connection, tableName, what, transaction), + where: await WhatToQueryGroupAsync(connection, tableName, what, transaction, cancellationToken), fields: fields, hints: hints, commandTimeout: commandTimeout, @@ -914,7 +914,7 @@ public static async Task UpdateAsync(this IDbConnection connection CancellationToken cancellationToken = default) where TEntity : class { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, transaction, cancellationToken); return await UpdateAsyncInternal(connection: connection, tableName: ClassMappedNameCache.Get(), entity: entity, @@ -959,7 +959,7 @@ public static async Task UpdateAsync(this IDbConnection con return await UpdateAsyncInternal(connection: connection, tableName: ClassMappedNameCache.Get(), entity: entity, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), fields: fields, hints: hints, commandTimeout: commandTimeout, @@ -999,7 +999,7 @@ public static async Task UpdateAsync(this IDbConnection connection return await UpdateAsyncInternal(connection: connection, tableName: ClassMappedNameCache.Get(), entity: entity, - where: await WhatToQueryGroupAsync(connection, what, transaction), + where: await WhatToQueryGroupAsync(connection, what, transaction, cancellationToken), fields: fields, hints: hints, commandTimeout: commandTimeout, @@ -1428,7 +1428,7 @@ public static async Task UpdateAsync(this IDbConnection connection, IStatementBuilder statementBuilder = null, CancellationToken cancellationToken = default) { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); return await UpdateAsyncInternal(connection: connection, tableName: tableName, entity: entity, diff --git a/RepoDb.Core/RepoDb/Operations/DbConnection/UpdateAll.cs b/RepoDb.Core/RepoDb/Operations/DbConnection/UpdateAll.cs index 467e94801..fdcba341f 100644 --- a/RepoDb.Core/RepoDb/Operations/DbConnection/UpdateAll.cs +++ b/RepoDb.Core/RepoDb/Operations/DbConnection/UpdateAll.cs @@ -777,7 +777,7 @@ internal static async Task UpdateAllAsyncInternal(this IDbConnecti { if (qualifiers?.Any() != true) { - var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction); + var key = await GetAndGuardPrimaryKeyOrIdentityKeyAsync(connection, tableName, transaction, cancellationToken); qualifiers = key.AsField().AsEnumerable(); } return await UpdateAllAsyncInternalBase(connection: connection, diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkDelete.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkDelete.cs index 1e1e0b596..80862c94e 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkDelete.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkDelete.cs @@ -1507,7 +1507,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout, batchSize, isReturnIdentity: false, @@ -1705,7 +1705,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout, batchSize, isReturnIdentity: false, diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkMerge.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkMerge.cs index c78378bc9..c61bbe811 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkMerge.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkMerge.cs @@ -1348,7 +1348,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1384,7 +1384,7 @@ await BulkInsertAsyncInternal(connection: connection, { var func = Compiler.GetPropertySetterFunc(identityDbField.Name); var list = entities.AsList(); - while (await reader.ReadAsync()) + while (await reader.ReadAsync(cancellationToken)) { var value = Converter.DbNullToNull(await reader.GetFieldValueAsync(0, cancellationToken)); var entity = list[result]; @@ -1566,7 +1566,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1758,7 +1758,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkUpdate.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkUpdate.cs index 2352df5be..2b0b1d6ff 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkUpdate.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/Microsoft.Data.SqlClient/SqlConnection/BulkUpdate.cs @@ -1087,7 +1087,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1282,7 +1282,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkDelete.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkDelete.cs index 1a3b6e9f7..ca4cec3cb 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkDelete.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkDelete.cs @@ -1507,7 +1507,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout, batchSize, isReturnIdentity: false, @@ -1705,7 +1705,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout, batchSize, isReturnIdentity: false, diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkInsert.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkInsert.cs index cb93cac0f..766644875 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkInsert.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkInsert.cs @@ -1365,7 +1365,7 @@ internal static async Task BulkInsertAsyncInternal(SqlConnection c var list = entities.AsList(); while (await reader.ReadAsync(cancellationToken)) { - var value = Converter.DbNullToNull(await reader.GetFieldValueAsync(0)); + var value = Converter.DbNullToNull(await reader.GetFieldValueAsync(0, cancellationToken)); var entity = list[result]; func(entity, value); result++; @@ -1467,7 +1467,7 @@ internal static async Task BulkInsertAsyncInternal(SqlConnection connection try { // Get the DB Fields - dbFields = dbFields ?? await DbFieldCache.GetAsync(connection, tableName, transaction, true); + dbFields = dbFields ?? await DbFieldCache.GetAsync(connection, tableName, transaction, true, cancellationToken); // Variables needed var identityDbField = dbFields?.FirstOrDefault(dbField => dbField.IsIdentity); @@ -1678,7 +1678,7 @@ internal static async Task BulkInsertAsyncInternal(SqlConnection connection try { // Get the DB Fields - dbFields = dbFields ?? await DbFieldCache.GetAsync(connection, tableName, transaction, true); + dbFields = dbFields ?? await DbFieldCache.GetAsync(connection, tableName, transaction, true, cancellationToken); // Variables needed var identityDbField = dbFields?.FirstOrDefault(dbField => dbField.IsIdentity); diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkMerge.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkMerge.cs index 5983aee87..12cdfc02e 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkMerge.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkMerge.cs @@ -1348,7 +1348,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1384,9 +1384,9 @@ await BulkInsertAsyncInternal(connection: connection, { var func = Compiler.GetPropertySetterFunc(identityDbField.Name); var list = entities.AsList(); - while (await reader.ReadAsync()) + while (await reader.ReadAsync(cancellationToken)) { - var value = Converter.DbNullToNull(await reader.GetFieldValueAsync(0)); + var value = Converter.DbNullToNull(await reader.GetFieldValueAsync(0, cancellationToken)); var entity = list[result]; func(entity, value); result++; @@ -1566,7 +1566,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1756,7 +1756,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1798,7 +1798,7 @@ await BulkInsertAsyncInternal(connection: connection, { using (var reader = (DbDataReader)(await connection.ExecuteReaderAsync(sql, commandTimeout: bulkCopyTimeout, transaction: transaction, cancellationToken: cancellationToken))) { - while (await reader.ReadAsync()) + while (await reader.ReadAsync(cancellationToken)) { var value = Converter.DbNullToNull((await reader.GetFieldValueAsync(0, cancellationToken))); dataTable.Rows[result][column] = value; diff --git a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkUpdate.cs b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkUpdate.cs index 673b2d9b5..7bd045f55 100644 --- a/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkUpdate.cs +++ b/RepoDb.Extensions/RepoDb.SqlServer.BulkOperations/RepoDb.SqlServer.BulkOperations/System.Data.SqlClient/SqlConnection/BulkUpdate.cs @@ -1087,7 +1087,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false, @@ -1282,7 +1282,7 @@ await BulkInsertAsyncInternal(connection: connection, dbFields: filteredDbFields, mappings: mappings, options: options, - hints: null, + hints: hints, bulkCopyTimeout: bulkCopyTimeout, batchSize: batchSize, isReturnIdentity: false,