Ejemplo n.º 1
0
        /// <summary>
        /// Generic construtor based on a specific DbContext.
        /// </summary>
        /// <param name="dbContext"></param>
        public GenericRepository(GenericContext <TContext> dbContext)
        {
            _dbContext = dbContext ?? throw new ArgumentNullException("dbContext");
            _dbContext.SetTrackingBehavior();

            try
            {
                DbSet = dbContext.Set <TEntity>();
            }
            catch (InvalidOperationException ex)
            {
                throw new Exception(string.Format(Errors.Possible_0, $"map the entity: {this.GetType().Name}"), ex);
            }
        }
Ejemplo n.º 2
0
 public GenericUnitOfWork(GenericContext <TContext> dbContext)
 {
     _dbContext = dbContext ?? throw new ArgumentNullException("dbContext");;
     _dbContext.SetTrackingBehavior();
 }