public EFUnitOfWork(IEFSession <TContext> context) { if (context == null) { throw new ArgumentNullException("context"); } _entityFrameworkContext = context; }
/// <summary> /// Default Init. /// </summary> protected virtual void Initialize() { if (ServiceLocator.Current == null) { return; } var sessions = ServiceLocator.Current.GetAllInstances <IEFSession>(); if (sessions != null && sessions.Count() > 0) { _privateSession = sessions.First(); } }
private void Dispose(bool disposing) { if (!disposing) { return; } if (_disposed) { return; } if (_transaction != null) { _transaction.Dispose(); _transaction = null; } if (_entityFrameworkContext != null) { _entityFrameworkContext.Dispose(); _entityFrameworkContext = null; } _disposed = true; }
/// <summary> /// Disposes off the managed and unmanaged resources used. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { if (!disposing) { return; } if (_disposed) { return; } if (_transaction != null) { _transaction.Dispose(); _transaction = null; } if (_session != null) { _session.Dispose(); _session = null; } _disposed = true; }
/// <summary> /// Default Constructor. /// Creates a new instance of the <see cref="LinqToSqlUnitOfWork"/> class that uses the specified data context. /// </summary> /// <param name="context">The <see cref="DataContext"/> instance that the LinqToSqlUnitOfWork instance uses.</param> public LinqToSqlUnitOfWork(IEFSession context) { Throw.Against<ArgumentNullException>(context == null, "Expected a non-nul DataContext instance"); _linqContext = context; }
/// <summary> /// Disposes off manages resources used by the LinqToSqlUnitOfWork instance. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { if (!disposing) return; if (_disposed) return; if (_transaction != null) { _transaction.Dispose(); _transaction = null; } if (_linqContext != null) { _linqContext.Dispose(); _linqContext = null; } _disposed = true; }
/// <summary> /// Default Constructor. /// Creates a new instance of the <see cref="EFUnitOfWork"/> class that uses the specified object context. /// </summary> /// <param name="session">The <see cref="IEFSession"/> instance that the EFUnitOfWork instance uses.</param> public EFUnitOfWork(IEFSession session) { Guard.Against <ArgumentNullException>(session == null, "Expected a non-null ObjectContext instance."); _session = session; }
/// <summary> /// Default Constructor. /// Creates a new instance of the <see cref="EFUnitOfWork"/> class that uses the specified object context. /// </summary> /// <param name="session">The <see cref="IEFSession"/> instance that the EFUnitOfWork instance uses.</param> public EFUnitOfWork(IEFSession session) { Guard.Against<ArgumentNullException>(session == null, "Expected a non-null ObjectContext instance."); _session = session; }
/// <summary> /// Disposes off the managed and unmanaged resources used. /// </summary> /// <param name="disposing"></param> private void Dispose(bool disposing) { if (!disposing) return; if (_disposed) return; if (_transaction != null) { _transaction.Dispose(); _transaction = null; } if (_session != null) { _session.Dispose(); _session = null; } _disposed = true; }