- 增加 Async CancellationToken IDelete;

This commit is contained in:
2881099 2020-11-12 06:43:45 +08:00
parent 8bbb7329f9
commit 37cd18d7c4
20 changed files with 51 additions and 48 deletions

View File

@ -130,13 +130,6 @@
清空状态数据
</summary>
</member>
<member name="M:FreeSql.DbSet`1.RemoveAsync(System.Linq.Expressions.Expression{System.Func{`0,System.Boolean}})">
<summary>
根据 lambda 条件删除数据
</summary>
<param name="predicate"></param>
<returns></returns>
</member>
<member name="M:FreeSql.DbSet`1.Add(`0)">
<summary>
添加
@ -509,14 +502,5 @@
<param name="that"></param>
<returns></returns>
</member>
<member name="M:Microsoft.Extensions.DependencyInjection.FreeSqlRepositoryDependencyInjection.AddFreeRepository(Microsoft.Extensions.DependencyInjection.IServiceCollection,System.Action{FreeSql.FluentDataFilter},System.Reflection.Assembly[])">
<summary>
批量注入 Repository可以参考代码自行调整
</summary>
<param name="services"></param>
<param name="globalDataFilter"></param>
<param name="assemblies"></param>
<returns></returns>
</member>
</members>
</doc>

View File

@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data.Common;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql
@ -109,8 +110,8 @@ namespace FreeSql
#if net40
#else
Task<int> ExecuteAffrowsAsync();
Task<List<T1>> ExecuteDeletedAsync();
Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default);
Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default);
#endif
}
}

View File

@ -5,6 +5,7 @@ using System.Data;
using System.Data.Common;
using System.Linq.Expressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Internal.CommonProvider
@ -13,7 +14,7 @@ namespace FreeSql.Internal.CommonProvider
{
#if net40
#else
async public Task<int> ExecuteAffrowsAsync()
async public Task<int> ExecuteAffrowsAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return 0;
@ -24,7 +25,7 @@ namespace FreeSql.Internal.CommonProvider
Exception exception = null;
try
{
affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{
@ -39,7 +40,7 @@ namespace FreeSql.Internal.CommonProvider
this.ClearData();
return affrows;
}
public abstract Task<List<T1>> ExecuteDeletedAsync();
public abstract Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default);
#endif
}
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Dameng.Curd
@ -22,7 +23,7 @@ namespace FreeSql.Dameng.Curd
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Firebird.Curd
@ -56,7 +57,7 @@ namespace FreeSql.Firebird.Curd
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Firebird.Curd
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.KingbaseES
@ -56,7 +57,7 @@ namespace FreeSql.KingbaseES
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.KingbaseES
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.MsAccess.Curd
@ -22,7 +23,7 @@ namespace FreeSql.MsAccess.Curd
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.MySql.Curd
@ -56,7 +57,7 @@ namespace FreeSql.MySql.Curd
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.MySql.Curd
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.Dameng
@ -22,7 +23,7 @@ namespace FreeSql.Odbc.Dameng
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.Default
@ -19,7 +20,7 @@ namespace FreeSql.Odbc.Default
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync() => throw new NotImplementedException("FreeSql.Odbc.Default 未实现该功能");
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default) => throw new NotImplementedException("FreeSql.Odbc.Default 未实现该功能");
#endif
}
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.KingbaseES
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.KingbaseES
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.KingbaseES
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.MySql
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.MySql
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.MySql
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.Oracle
@ -22,7 +23,7 @@ namespace FreeSql.Odbc.Oracle
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.PostgreSQL
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.PostgreSQL
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.PostgreSQL
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Odbc.SqlServer
@ -61,7 +62,7 @@ namespace FreeSql.Odbc.SqlServer
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -89,7 +90,7 @@ namespace FreeSql.Odbc.SqlServer
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Oracle.Curd
@ -22,7 +23,7 @@ namespace FreeSql.Oracle.Curd
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.PostgreSQL.Curd
@ -56,7 +57,7 @@ namespace FreeSql.PostgreSQL.Curd
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.PostgreSQL.Curd
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.ShenTong.Curd
@ -56,7 +57,7 @@ namespace FreeSql.ShenTong.Curd
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.ShenTong.Curd
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.SqlServer.Curd
@ -61,7 +62,7 @@ namespace FreeSql.SqlServer.Curd
#if net40
#else
async public override Task<List<T1>> ExecuteDeletedAsync()
async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -89,7 +90,7 @@ namespace FreeSql.SqlServer.Curd
Exception exception = null;
try
{
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms);
ret = await _orm.Ado.QueryAsync<T1>(_table.TypeLazy ?? _table.Type, _connection, _transaction, CommandType.Text, sql, _commandTimeout, dbParms, cancellationToken);
}
catch (Exception ex)
{

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace FreeSql.Sqlite.Curd
@ -22,7 +23,7 @@ namespace FreeSql.Sqlite.Curd
#if net40
#else
public override Task<List<T1>> ExecuteDeletedAsync()
public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}