/// <summary> /// 计算要插入、更新或删除的已修改对象的集,并执行相应命令以实现对数据库的更改 /// </summary> /// <returns></returns> public async Task <int> SubmitChangesAsync() { int count = _dbQueryables.Count; if (count == 0) { return(0); } IDbConnection conn = null; IDbTransaction trans = null; try { List <string> sqlList = this.Resolve(false); conn = await _provider.CreateConnectionAsync(true); if (count > 1) { trans = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); } var result = await _provider.ExecuteAsync(sqlList, trans); this.SetIdentity(result); if (trans != null) { trans.Commit(); } } catch { if (trans != null) { trans.Rollback(); } throw; } finally { if (trans != null) { trans.Dispose(); } if (conn != null) { conn.Close(); } if (conn != null) { conn.Dispose(); } this.Dispose(); } return(count); }