From b25bcf8ee5658af59b9981f09b80ac171661cbe8 Mon Sep 17 00:00:00 2001 From: 2881099 <2881099@qq.com> Date: Thu, 12 Nov 2020 06:48:52 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E5=A2=9E=E5=8A=A0=20Async=20CancellationTo?= =?UTF-8?q?ken=20OnDuplicateKeyUpdate/OnConflictDoUpdate=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Curd/KingbaseESOnConflictDoUpdate.cs | 5 +++-- .../FreeSql.Provider.MySql/Curd/OnDuplicateKeyUpdate.cs | 5 +++-- .../KingbaseES/Curd/OdbcKingbaseESOnConflictDoUpdate.cs | 5 +++-- .../MySql/Curd/OdbcMySqlOnDuplicateKeyUpdate.cs | 5 +++-- .../PostgreSQL/Curd/OdbcPostgreSQLOnConflictDoUpdate.cs | 5 +++-- .../FreeSql.Provider.PostgreSQL/Curd/OnConflictDoUpdate.cs | 5 +++-- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Providers/FreeSql.Provider.KingbaseES/Curd/KingbaseESOnConflictDoUpdate.cs b/Providers/FreeSql.Provider.KingbaseES/Curd/KingbaseESOnConflictDoUpdate.cs index b550fd08..aa86a9d9 100644 --- a/Providers/FreeSql.Provider.KingbaseES/Curd/KingbaseESOnConflictDoUpdate.cs +++ b/Providers/FreeSql.Provider.KingbaseES/Curd/KingbaseESOnConflictDoUpdate.cs @@ -6,6 +6,7 @@ using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.KingbaseES @@ -177,7 +178,7 @@ namespace FreeSql.KingbaseES #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -188,7 +189,7 @@ namespace FreeSql.KingbaseES Exception exception = null; try { - ret = await _insert.InternalOrm.Ado.ExecuteNonQueryAsync(_insert.InternalConnection, _insert.InternalTransaction, CommandType.Text, sql, _insert._commandTimeout, _insert.InternalParams); + ret = await _insert.InternalOrm.Ado.ExecuteNonQueryAsync(_insert.InternalConnection, _insert.InternalTransaction, CommandType.Text, sql, _insert._commandTimeout, _insert.InternalParams, cancellationToken); } catch (Exception ex) { diff --git a/Providers/FreeSql.Provider.MySql/Curd/OnDuplicateKeyUpdate.cs b/Providers/FreeSql.Provider.MySql/Curd/OnDuplicateKeyUpdate.cs index 7ce2055f..14205596 100644 --- a/Providers/FreeSql.Provider.MySql/Curd/OnDuplicateKeyUpdate.cs +++ b/Providers/FreeSql.Provider.MySql/Curd/OnDuplicateKeyUpdate.cs @@ -3,6 +3,7 @@ using System; using System.Data; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.MySql.Curd @@ -136,7 +137,7 @@ namespace FreeSql.MySql.Curd #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -147,7 +148,7 @@ namespace FreeSql.MySql.Curd Exception exception = null; try { - ret = await _mysqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_mysqlInsert.InternalConnection, _mysqlInsert.InternalTransaction, CommandType.Text, sql, _mysqlInsert._commandTimeout, _mysqlInsert.InternalParams); + ret = await _mysqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_mysqlInsert.InternalConnection, _mysqlInsert.InternalTransaction, CommandType.Text, sql, _mysqlInsert._commandTimeout, _mysqlInsert.InternalParams, cancellationToken); } catch (Exception ex) { diff --git a/Providers/FreeSql.Provider.Odbc/KingbaseES/Curd/OdbcKingbaseESOnConflictDoUpdate.cs b/Providers/FreeSql.Provider.Odbc/KingbaseES/Curd/OdbcKingbaseESOnConflictDoUpdate.cs index 4e0b3774..3ff78116 100644 --- a/Providers/FreeSql.Provider.Odbc/KingbaseES/Curd/OdbcKingbaseESOnConflictDoUpdate.cs +++ b/Providers/FreeSql.Provider.Odbc/KingbaseES/Curd/OdbcKingbaseESOnConflictDoUpdate.cs @@ -6,6 +6,7 @@ using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.Odbc.KingbaseES @@ -177,7 +178,7 @@ namespace FreeSql.Odbc.KingbaseES #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -188,7 +189,7 @@ namespace FreeSql.Odbc.KingbaseES Exception exception = null; try { - ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams); + ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams, cancellationToken); } catch (Exception ex) { diff --git a/Providers/FreeSql.Provider.Odbc/MySql/Curd/OdbcMySqlOnDuplicateKeyUpdate.cs b/Providers/FreeSql.Provider.Odbc/MySql/Curd/OdbcMySqlOnDuplicateKeyUpdate.cs index 92868d26..ae552a90 100644 --- a/Providers/FreeSql.Provider.Odbc/MySql/Curd/OdbcMySqlOnDuplicateKeyUpdate.cs +++ b/Providers/FreeSql.Provider.Odbc/MySql/Curd/OdbcMySqlOnDuplicateKeyUpdate.cs @@ -3,6 +3,7 @@ using System; using System.Data; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.Odbc.MySql @@ -136,7 +137,7 @@ namespace FreeSql.Odbc.MySql #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -147,7 +148,7 @@ namespace FreeSql.Odbc.MySql Exception exception = null; try { - ret = await _mysqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_mysqlInsert.InternalConnection, _mysqlInsert.InternalTransaction, CommandType.Text, sql, _mysqlInsert._commandTimeout, _mysqlInsert.InternalParams); + ret = await _mysqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_mysqlInsert.InternalConnection, _mysqlInsert.InternalTransaction, CommandType.Text, sql, _mysqlInsert._commandTimeout, _mysqlInsert.InternalParams, cancellationToken); } catch (Exception ex) { diff --git a/Providers/FreeSql.Provider.Odbc/PostgreSQL/Curd/OdbcPostgreSQLOnConflictDoUpdate.cs b/Providers/FreeSql.Provider.Odbc/PostgreSQL/Curd/OdbcPostgreSQLOnConflictDoUpdate.cs index 2a2f302b..3f1262a0 100644 --- a/Providers/FreeSql.Provider.Odbc/PostgreSQL/Curd/OdbcPostgreSQLOnConflictDoUpdate.cs +++ b/Providers/FreeSql.Provider.Odbc/PostgreSQL/Curd/OdbcPostgreSQLOnConflictDoUpdate.cs @@ -6,6 +6,7 @@ using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.Odbc.PostgreSQL @@ -177,7 +178,7 @@ namespace FreeSql.Odbc.PostgreSQL #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -188,7 +189,7 @@ namespace FreeSql.Odbc.PostgreSQL Exception exception = null; try { - ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams); + ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams, cancellationToken); } catch (Exception ex) { diff --git a/Providers/FreeSql.Provider.PostgreSQL/Curd/OnConflictDoUpdate.cs b/Providers/FreeSql.Provider.PostgreSQL/Curd/OnConflictDoUpdate.cs index 5ab98652..383910d0 100644 --- a/Providers/FreeSql.Provider.PostgreSQL/Curd/OnConflictDoUpdate.cs +++ b/Providers/FreeSql.Provider.PostgreSQL/Curd/OnConflictDoUpdate.cs @@ -6,6 +6,7 @@ using System.Data; using System.Linq; using System.Linq.Expressions; using System.Text; +using System.Threading; using System.Threading.Tasks; namespace FreeSql.PostgreSQL.Curd @@ -177,7 +178,7 @@ namespace FreeSql.PostgreSQL.Curd #if net40 #else - async public Task ExecuteAffrowsAsync() + async public Task ExecuteAffrowsAsync(CancellationToken cancellationToken = default) { var sql = this.ToSql(); if (string.IsNullOrEmpty(sql)) return 0; @@ -188,7 +189,7 @@ namespace FreeSql.PostgreSQL.Curd Exception exception = null; try { - ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams); + ret = await _pgsqlInsert.InternalOrm.Ado.ExecuteNonQueryAsync(_pgsqlInsert.InternalConnection, _pgsqlInsert.InternalTransaction, CommandType.Text, sql, _pgsqlInsert._commandTimeout, _pgsqlInsert.InternalParams, cancellationToken); } catch (Exception ex) {