예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdoNetRepositoryContext" /> class.
        /// </summary>
        /// <param name="existingConnection">The existing connection.</param>
        /// <param name="ensureDatabaseCreated">
        /// Ensures that the database for the context exists. If it exists, no action is taken.
        /// If it does not exist then the database and all its schema are created.
        /// If the database exists, then no effort is made to ensure it is compatible with the model for this context.
        /// </param>
        public AdoNetRepositoryContext(DbConnection existingConnection, bool ensureDatabaseCreated = false)
        {
            Guard.NotNull(existingConnection, nameof(existingConnection));

            Conventions = RepositoryConventions.Default;

            _dbHelper              = new DbHelper(Conventions, existingConnection);
            _schemaConfigHelper    = new SchemaTableConfigurationHelper(Conventions, _dbHelper);
            _ensureDatabaseCreated = ensureDatabaseCreated;
        }
예제 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdoNetRepositoryContext" /> class.
        /// </summary>
        /// <param name="nameOrConnectionString">Either the database name or a connection string.</param>
        /// <param name="ensureDatabaseCreated">
        /// Ensures that the database for the context exists. If it exists, no action is taken.
        /// If it does not exist then the database and all its schema are created.
        /// If the database exists, then no effort is made to ensure it is compatible with the model for this context.
        /// </param>
        public AdoNetRepositoryContext(string nameOrConnectionString, bool ensureDatabaseCreated = false)
        {
            Guard.NotEmpty(nameOrConnectionString, nameof(nameOrConnectionString));

            Conventions = RepositoryConventions.Default;

            _dbHelper              = new DbHelper(Conventions, nameOrConnectionString);
            _schemaConfigHelper    = new SchemaTableConfigurationHelper(Conventions, _dbHelper);
            _ensureDatabaseCreated = ensureDatabaseCreated;
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AdoNetRepositoryContext" /> class.
        /// </summary>
        /// <param name="providerName">The name of the provider.</param>
        /// <param name="connectionString">The connection string.</param>
        /// <param name="ensureDatabaseCreated">
        /// Ensures that the database for the context exists. If it exists, no action is taken.
        /// If it does not exist then the database and all its schema are created.
        /// If the database exists, then no effort is made to ensure it is compatible with the model for this context.
        /// </param>
        public AdoNetRepositoryContext(string providerName, string connectionString, bool ensureDatabaseCreated = false)
        {
            Guard.NotEmpty(providerName, nameof(providerName));
            Guard.NotEmpty(connectionString, nameof(connectionString));

            Conventions = RepositoryConventions.Default <AdoNetRepositoryContext>();

            _dbHelper              = new DbHelper(Conventions, providerName, connectionString);
            _schemaConfigHelper    = new SchemaTableConfigurationHelper(_dbHelper);
            _ensureDatabaseCreated = ensureDatabaseCreated;
            _loggerProvider        = NullLoggerProvider.Instance;
        }