/// <summary> /// Save all changes to a storage. /// </summary> /// <returns>Returns number of objects saved to the storage.</returns> public int SaveChanges() { ThrowIfDisposed(); int retCount = 0; IDbTransactionContext privateTContext = null; Open(); // MySQL does not support nested transaction as if this class is used with // unit of work which wraps operation inside a transaction. So, checking for // existing transaction before creating private transaction context. if (!TransactionExists) { privateTContext = CreateDbTransactionContext(); } try { foreach (IDbCommandContext cmdContext in _cmdList) { retCount += cmdContext.Execute(); cmdContext.Dispose(); } if (privateTContext != null) { privateTContext.Commit(); } } catch (Exception) { if (privateTContext != null) { privateTContext.Rollback(); } throw; } finally { if (privateTContext != null) { privateTContext.Dispose(); } _cmdList.Clear(); Close(); } return retCount; }
public void Commit() { _context.Commit(); }