/// <summary> /// 计算要插入、更新或删除的已修改对象的集,并执行相应命令以实现对数据库的更改 /// </summary> /// <returns></returns> public int SubmitChanges() { int count = _dbQueryables.Count; if (count == 0) return 0; IDbConnection conn = null; IDbTransaction trans = null; try { List<string> sqlList = this.Resolve(false); conn = _provider.CreateConnection(true); if (count > 1) trans = conn.BeginTransaction(System.Data.IsolationLevel.ReadCommitted); var result = _provider.Execute(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; }