## v0.3.11

- 增加 ISelect、IInsert、IUpdate、IDelete WithTransaction 方法,将事务对象暴露给外部;
- 增加 IAdo ExecuteXxx 系列方法重载,支持事务对象的传入;
This commit is contained in:
28810
2019-03-11 17:26:27 +08:00
parent c14dd0c169
commit 4f66c3b9eb
29 changed files with 216 additions and 115 deletions

View File

@@ -19,6 +19,7 @@ namespace FreeSql.Internal.CommonProvider {
protected TableInfo _table;
protected Func<string, string> _tableRule;
protected DbParameter[] _params;
protected DbTransaction _transaction;
public InsertProvider(IFreeSql orm, CommonUtils commonUtils, CommonExpression commonExpression) {
_orm = orm;
@@ -28,6 +29,11 @@ namespace FreeSql.Internal.CommonProvider {
if (_orm.CodeFirst.IsAutoSyncStructure) _orm.CodeFirst.SyncStructure<T1>();
}
public IInsert<T1> WithTransaction(DbTransaction transaction) {
_transaction = transaction;
return this;
}
public IInsert<T1> AppendData(T1 source) {
if (source != null) _source.Add(source);
return this;
@@ -37,8 +43,8 @@ namespace FreeSql.Internal.CommonProvider {
return this;
}
public int ExecuteAffrows() => _orm.Ado.ExecuteNonQuery(CommandType.Text, this.ToSql(), _params);
public Task<int> ExecuteAffrowsAsync() => _orm.Ado.ExecuteNonQueryAsync(CommandType.Text, this.ToSql(), _params);
public int ExecuteAffrows() => _orm.Ado.ExecuteNonQuery(_transaction, CommandType.Text, this.ToSql(), _params);
public Task<int> ExecuteAffrowsAsync() => _orm.Ado.ExecuteNonQueryAsync(_transaction, CommandType.Text, this.ToSql(), _params);
public abstract long ExecuteIdentity();
public abstract Task<long> ExecuteIdentityAsync();
public abstract List<T1> ExecuteInserted();