- 增加 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> </summary>
</member> </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)"> <member name="M:FreeSql.DbSet`1.Add(`0)">
<summary> <summary>
添加 添加
@ -509,14 +502,5 @@
<param name="that"></param> <param name="that"></param>
<returns></returns> <returns></returns>
</member> </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> </members>
</doc> </doc>

View File

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

View File

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

View File

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

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Firebird.Curd namespace FreeSql.Firebird.Curd
@ -56,7 +57,7 @@ namespace FreeSql.Firebird.Curd
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Firebird.Curd
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.KingbaseES namespace FreeSql.KingbaseES
@ -56,7 +57,7 @@ namespace FreeSql.KingbaseES
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.KingbaseES
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

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

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.MySql.Curd namespace FreeSql.MySql.Curd
@ -56,7 +57,7 @@ namespace FreeSql.MySql.Curd
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.MySql.Curd
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

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

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Odbc.Default namespace FreeSql.Odbc.Default
@ -19,7 +20,7 @@ namespace FreeSql.Odbc.Default
#if net40 #if net40
#else #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 #endif
} }
} }

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Odbc.KingbaseES namespace FreeSql.Odbc.KingbaseES
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.KingbaseES
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.KingbaseES
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Odbc.MySql namespace FreeSql.Odbc.MySql
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.MySql
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.MySql
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

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

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Odbc.PostgreSQL namespace FreeSql.Odbc.PostgreSQL
@ -56,7 +57,7 @@ namespace FreeSql.Odbc.PostgreSQL
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.Odbc.PostgreSQL
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.Odbc.SqlServer namespace FreeSql.Odbc.SqlServer
@ -61,7 +62,7 @@ namespace FreeSql.Odbc.SqlServer
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -89,7 +90,7 @@ namespace FreeSql.Odbc.SqlServer
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

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

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.PostgreSQL.Curd namespace FreeSql.PostgreSQL.Curd
@ -56,7 +57,7 @@ namespace FreeSql.PostgreSQL.Curd
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.PostgreSQL.Curd
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.ShenTong.Curd namespace FreeSql.ShenTong.Curd
@ -56,7 +57,7 @@ namespace FreeSql.ShenTong.Curd
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -79,7 +80,7 @@ namespace FreeSql.ShenTong.Curd
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

@ -3,6 +3,7 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Text; using System.Text;
using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace FreeSql.SqlServer.Curd namespace FreeSql.SqlServer.Curd
@ -61,7 +62,7 @@ namespace FreeSql.SqlServer.Curd
#if net40 #if net40
#else #else
async public override Task<List<T1>> ExecuteDeletedAsync() async public override Task<List<T1>> ExecuteDeletedAsync(CancellationToken cancellationToken = default)
{ {
var sql = this.ToSql(); var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return new List<T1>(); if (string.IsNullOrEmpty(sql)) return new List<T1>();
@ -89,7 +90,7 @@ namespace FreeSql.SqlServer.Curd
Exception exception = null; Exception exception = null;
try 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) catch (Exception ex)
{ {

View File

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