/// <summary>
        /// Initialize a new <see cref="MaijeDbContextHealthCheck"/>
        /// </summary>
        /// <param name="maijeDbContext">The maije data context</param>
        public MaijeDbContextHealthCheck(IMaijeDbContext maijeDbContext)
        {
            _dbContext = maijeDbContext as DbContext;

            if (_dbContext == null)
            {
                throw new ArgumentException("The IMaijeDbContext must implement DbContext");
            }
        }
Example #2
0
        /// <summary>
        /// Initialize a new <see cref="MaijeRepository{TEntity, TIdentifier}"/>
        /// </summary>
        /// <param name="databaseContext">The database context</param>
        public MaijeRepository(IMaijeDbContext databaseContext, IPaginationDomainService paginationDomainService)
        {
            _paginationDomainService = paginationDomainService ?? throw new ArgumentNullException(nameof(paginationDomainService));

            if (databaseContext == null)
            {
                throw new ArgumentNullException(nameof(databaseContext));
            }

            // We don't give access to the data context to prevent usage of SaveChanges() and other stuff
            // So we only store DbSet
            DbSet = databaseContext.Set <TEntity>() as DbSet <TEntity>; // Ugly cast, maybe wa can find a better way

            if (DbSet == null)
            {
                throw new InfrastructureException($"The {nameof(databaseContext)} must be a MaijeDbContext to work with repository.");
            }
        }
Example #3
0
 /// <summary>
 /// Initialize a new <see cref="DeactivatableMaijeRepository{TEntity, TIdentifier}"/>
 /// </summary>
 /// <param name="databaseContext">The database context</param>
 public DeactivatableMaijeRepository(IMaijeDbContext databaseContext, IPaginationDomainService paginationDomainService) : base(databaseContext, paginationDomainService)
 {
 }
Example #4
0
 /// <summary>
 /// Initialize an <see cref="UnitOfWorkBase"/>
 /// </summary>
 /// <param name="dbContext"></param>
 public UnitOfWork(IMaijeDbContext dbContext, IEnumerable <IMaijeRepository> repositories)
 {
     _dbContext             = dbContext ?? throw new ArgumentNullException(nameof(dbContext));
     _availableRepositories = repositories ?? throw new ArgumentNullException(nameof(repositories));
 }
Example #5
0
 public PostRepository(IMaijeDbContext databaseContext, IPaginationDomainService paginationDomainService) : base(databaseContext, paginationDomainService)
 {
 }