public Repository(IDBConnectionFactory connectionFactory, ILogger <Repository <T> > logger)
        {
            Type TypeT = typeof(T);

            ctor = TypeT.GetConstructor(Type.EmptyTypes);
            if (ctor == null)
            {
                throw new InvalidOperationException($"Type {TypeT.Name} does not have a default constructor.");
            }

            var tableName = TypeT.GetTableName();

            if (string.IsNullOrEmpty(tableName))
            {
                throw new InvalidOperationException($"{nameof(TableAttribute)} is missing from type {TypeT.Name}.");
            }

            idColumnName = TypeT.GetIdColumnName();
            if (string.IsNullOrEmpty(idColumnName))
            {
                throw new InvalidOperationException($"{nameof(IdAttribute)} is missing from type {TypeT.Name}.");
            }

            connection  = connectionFactory.GetDbConnection();
            this.logger = logger;
        }
Example #2
0
 /// <summary>
 /// Construct a <see cref="SetupWizard"/>
 /// </summary>
 /// <param name="ioManager">The value of <see cref="ioManager"/></param>
 /// <param name="console">The value of <see cref="console"/></param>
 /// <param name="hostingEnvironment">The value of <see cref="hostingEnvironment"/></param>
 /// <param name="application">The value of <see cref="application"/></param>
 /// <param name="dbConnectionFactory">The value of <see cref="dbConnectionFactory"/></param>
 /// <param name="logger">The value of <see cref="logger"/></param>
 /// <param name="generalConfigurationOptions">The <see cref="IOptions{TOptions}"/> containing the value of <see cref="generalConfiguration"/></param>
 public SetupWizard(IIOManager ioManager, IConsole console, IHostingEnvironment hostingEnvironment, IApplication application, IDBConnectionFactory dbConnectionFactory, ILogger <SetupWizard> logger, IOptions <GeneralConfiguration> generalConfigurationOptions)
 {
     this.ioManager           = ioManager ?? throw new ArgumentNullException(nameof(ioManager));
     this.console             = console ?? throw new ArgumentNullException(nameof(console));
     this.hostingEnvironment  = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     this.application         = application ?? throw new ArgumentNullException(nameof(application));
     this.dbConnectionFactory = dbConnectionFactory ?? throw new ArgumentNullException(nameof(dbConnectionFactory));
     this.logger          = logger ?? throw new ArgumentNullException(nameof(logger));
     generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions));
 }
Example #3
0
        public void RegisterPlugin(string name, IDBConnectionFactory factory)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }
            Contract.EndContractBlock();

            _cachedPluginNames    = null;
            _pluginRegistry[name] = factory;
        }
 public static Task <IDbConnection> GetAsync(this IDBConnectionFactory factory)
 {
     return(factory.GetAsync(DefaultName));
 }
Example #5
0
 public AuthRepository(IDBConnectionFactory connectionFactory, ISendingEmail emailFactory) : base(connectionFactory)
 {
     _emailFactory = emailFactory;
 }
Example #6
0
 internal DatabaseConnect(IDBConnectionFactory factory)
 {
     _connectionFactory = factory;
 }
Example #7
0
 public DatabaseConnect()
 {
     _connectionFactory = new DBConnectionFactory();
 }
 public PageRepository(IDBConnectionFactory connectionFactory, ILogger <Repository <PageDTO> > logger) : base(connectionFactory, logger)
 {
 }
Example #9
0
 public CompanyRepository(IDBConnectionFactory connectionFactory) : base(connectionFactory)
 {
 }
Example #10
0
 public BaseRepository(IDBConnectionFactory connectionFactory)
 {
     _connectionFactory = connectionFactory;
 }
Example #11
0
 public MySqlSnapshotStore(IDBConnectionFactory factory)
 {
     this._factory = factory;
 }
Example #12
0
 public UserRepository(IDBConnectionFactory connFactory)
 {
     _connFactory = connFactory;
 }
 public MySqlEventStore(IDBConnectionFactory factory)
 {
     this._factory = factory;
 }
 public ProductRepository(IDBConnectionFactory connectionFactory, ILogger <Repository <ProductDTO> > logger) : base(connectionFactory, logger)
 {
 }
 public static IDbConnection Get(this IDBConnectionFactory factory)
 {
     return(factory.Get(DefaultName));
 }
 public static IDbConnection Get(this IDBConnectionFactory factory, string name)
 {
     return(factory.GetAsync(name).GetAwaiter().GetResult());
 }
Example #17
0
 public UserRepository(IDBConnectionFactory connectionFactory) : base(connectionFactory)
 {
 }