Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DbUnitOfWork"/> class.
        /// </summary>
        /// <param name="context">A <see cref="DomainContext"/> object.</param>
        /// <param name="dbName">An enumation <see cref="DatabaseName"/> for the database name to connect to.</param>
        /// <param name="baseRepository"></param>
        public DbUnitOfWork(DomainContext context, DatabaseName dbName = DatabaseName.Default, object baseRepository = null)
        {
            Guard.ArgumentNotNull(context, "context");
            Guard.ArgumentNotNull(dbName, "dbName");

            _context = context;
            _conn    = _context.CreateConnection(dbName);

            _repositories = new List <DbRepository>();

            if (baseRepository == null)
            {
                return;
            }

            var repositories = new List <IRepository> {
                (IRepository)baseRepository
            };

            Enlist(repositories.ToArray());
            InitTransaction();
        }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DbRepository"/> class.
 /// </summary>
 /// <param name="context">The domain context.</param>
 /// <param name="dbName"></param>
 protected DbRepository(DomainContext context, DatabaseName dbName = DatabaseName.Default)
 {
     Context       = context;
     IsEnlisted    = false;
     CurrentDbName = dbName;
 }