Files
FreeSql/FreeSql/Internal/CommonProvider/DeleteProviderAsync.cs
28810 de8cf9e17d - 增加 .Net Framework 4.0 的支持,出于环境考虑 .Net Framework 4.0 不支持异步方法;
- 增加 IFreeSql.Insert<T>(IEnumerable<T1> source) 方法;
2019-10-21 15:14:18 +08:00

46 lines
1.3 KiB
C#

using FreeSql.Internal.Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace FreeSql.Internal.CommonProvider
{
partial class DeleteProvider<T1>
{
#if net40
#else
async public Task<int> ExecuteAffrowsAsync()
{
var sql = this.ToSql();
if (string.IsNullOrEmpty(sql)) return 0;
var dbParms = _params.ToArray();
var before = new Aop.CurdBeforeEventArgs(_table.Type, _table, Aop.CurdType.Delete, sql, dbParms);
_orm.Aop.CurdBefore?.Invoke(this, before);
var affrows = 0;
Exception exception = null;
try
{
affrows = await _orm.Ado.ExecuteNonQueryAsync(_connection, _transaction, CommandType.Text, sql, dbParms);
}
catch (Exception ex)
{
exception = ex;
throw ex;
}
finally
{
var after = new Aop.CurdAfterEventArgs(before, exception, affrows);
_orm.Aop.CurdAfter?.Invoke(this, after);
}
this.ClearData();
return affrows;
}
public abstract Task<List<T1>> ExecuteDeletedAsync();
#endif
}
}