EasyRepository/GenericUnitOfWork.cs
/// <inheritdoc />
/// <summary>
///   The commit transaction commits all pending context changes to the database.
/// </summary>
/// <exception cref="TransactionException">
///   Thrown when no transaction is present,
/// </exception>
/// <exception cref="InvalidOperationException">
///   Thrown in cases that the data context ise not usable or disposed.
/// </exception>
/// <exception cref="Exception">
///   Thrown on error comitting transactions.
/// </exception>
The commit transaction commits all pending context changes to the database.
The commit transaction commits all pending context changes to the database .
public void CommitTransaction()
        {
            this.EnsureContext();
            if (this.transactionScope == null)
            {
                throw new TransactionException("There is no current transaction");
            }
            try
            {
                this.context.SaveChanges();
                this.transactionScope.Commit();
            }
            catch (DbEntityValidationException ex)
            {
                this.RollbackTransaction();
                this.HandleDbEntityValidationException(ex);
            }
            catch (Exception ex)
            {
                this.RollbackTransaction();
                throw new Exception($"An error occured during the Commit transaction.\r\n{ex.Message}");
            }
            finally
            {
                var scope = this.transactionScope;
                scope?.Dispose();
                this.transactionScope = null;
            }
        }
public void CommitTransaction ( ) { this . EnsureContext ( ) ; if ( this . transactionScope == null ) { throw new TransactionException ( " " ) ; } try { this . context . SaveChanges ( ) ; this . transactionScope . Commit ( ) ; } catch ( DbEntityValidationException ex ) { this . RollbackTransaction ( ) ; this . HandleDbEntityValidationException ( ex ) ; } catch ( Exception ex ) { this . RollbackTransaction ( ) ; throw new Exception ( $" An error occured during the Commit transaction. \r \n { ex . Message } " ) ; } finally { var scope = this . transactionScope ; scope ? . Dispose ( ) ; this . transactionScope = null ; } }
The commit transaction commits all pending context changes to the database.
The commit transaction commits all pending context changes to the database .
Thrown when no transaction is present.
Thrown when no transaction is present .
Thrown in cases that the data context ise not usable or disposed.
Thrown in cases that the data context ise not usable or disposed .
Thrown on error comitting transactions.
Thrown on error comitting transactions .
inheritdoc
None