コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the SinglePartitionProvider using specified connection string instance.
        /// </summary>
        /// <param name="connectionString">Instance of the DatabaseConnectionString class.</param>
        public SinglePartitionProvider(DatabaseConnectionString connectionString)
        {
            if (connectionString == null)
                throw new ArgumentNullException("connectionString");

            ConnectionString = connectionString;
        }
コード例 #2
0
        public async Task Setup()
        {
            await DatabaseOrderDummyFiller.EmptyAndFillDatabases();

            string connectionString = DatabaseConnectionString.GetAzureConnectionString("ordertest");

            OrderService.dataAccess = new OrderDataAccessImplMySql(connectionString);
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new  instance of the KeyMapPartitionProvider class with specified connection to the partition map database.
        /// </summary>
        /// <param name="partitionMapConnectionString">Connection information to a database where to find the partition connection strings.</param>
        public KeyMapPartitionProvider(DatabaseConnectionString partitionMapConnectionString)
        {
            if (partitionMapConnectionString == null)
                throw new ArgumentNullException("partitionMapConnectionString");

            _connectionStrings = new ConnectionStringMap(partitionMapConnectionString);
            _partitionKeyCache = new ConcurrentDictionary<object, int>();
        }
コード例 #4
0
        public async Task Setup()
        {
            await DatabaseStockDummyFiller.EmptyAndFillDatabases();

            string connectionString = DatabaseConnectionString.GetAzureConnectionString("stocktest");

            StockService.dataAccess = new StockDataAccessImplMySql(connectionString);
        }
コード例 #5
0
        public async Task Setup()
        {
            await DatabaseLoginTestFiller.EmptyAndFillDatabases();

            string connectionString = DatabaseConnectionString.GetAzureConnectionString("logintest");

            UserService.dataAccess = new DataAccessImplMySql(connectionString);
        }
コード例 #6
0
 public TodoContext(
     DbContextOptions <TodoContext> options,
     DatabaseConnectionString connectionString,
     IWebHostEnvironment environment)
     : base(options)
 {
     _connectionString = connectionString;
     _isDevelopment    = environment.IsDevelopment();
 }
コード例 #7
0
        public async Task Setup()
        {
            await DatabaseLoginTestFiller.EmptyAndFillDatabases();

            await DatabaseProductDummyFiller.EmptyAndFillDatabases();

            string connectionString = DatabaseConnectionString.GetAzureConnectionString("producttest");

            ProductService.dataAccess = new DataAccessImplMySql(connectionString);
        }
コード例 #8
0
        /// <summary>
        /// Initialize an instance of the HashedPartitionProvider class with specified number of partitions.
        /// IMPORTANT NOTE: The number of partitions must never change for a given application as this implementation is not rebalancing. 
        /// </summary>
        /// <param name="partitionMapConnectionString">Connection information to a database where to find the partition connection strings.</param>
        public HashedPartitionProvider(DatabaseConnectionString partitionMapConnectionString)
        {
            if (partitionMapConnectionString == null)
                throw new ArgumentNullException("partitionMapConnectionString");

            try
            {
                CacheAllConnectionStrings(partitionMapConnectionString);
            }
            catch (Exception e)
            {
                throw new PartitionException(Resources.Text.internal_error_see_inner_exception, e);
            }
        }
コード例 #9
0
        public void property_update_succeeds()
        {
            var connectionString = "Server=(local); Database=HelloWorld; Application Name=Only the Best Will Do;";
            var sut = new DatabaseConnectionString();

            sut.ConnectionStringName = "MyDefaultConnectionStringName";

            using (new AssertionScope())
            {
                sut.ConnectionStringName.Should().Be("MyDefaultConnectionStringName");
                sut.ConnectionString.Should().Be("Server=(local); Database=HelloWorld; Application Name=TestTestTest;", "because we expect this to be the default connection string name");
                sut.ConnectionString = connectionString;
                sut.ConnectionString.Should().Be("Server=(local); Database=HelloWorld; Application Name=Only the Best Will Do;", "because the new connection string is valid");
            }
        }
コード例 #10
0
        /// <summary>
        /// Creates a partition which can grow automatically each time GetConnectionString is called for a new partition key.
        /// </summary>
        /// <param name="partition">Partition to create.</param>
        /// <param name="connectionString">Connection string to be used for the partition.</param>
        public void AddNewAutoAssignPartition(int partition, DatabaseConnectionString connectionString)
        {
            if (partition < 0)
                throw new ArgumentOutOfRangeException("partition");

            if (connectionString == null)
                throw new ArgumentNullException("connectionString");

            try
            {
                ExecuteAddNewPartition(partition, connectionString, true);
            }
            catch (Exception e)
            {
                throw new PartitionException(Resources.Text.internal_error_see_inner_exception, e);
            }
        }
コード例 #11
0
        void CacheAllConnectionStrings(DatabaseConnectionString partitionMapConnectionString)
        {
            _connectionStringCache = new Dictionary<int, DatabaseConnectionString>();

            using (new TransactionScope(TransactionScopeOption.Suppress))
            using (var connection = partitionMapConnectionString.CreateDbConnection())
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "GetApplicationConnectionStrings";
                command.CommandType = CommandType.StoredProcedure;

                connection.Open();

                using (var reader = command.ExecuteReader())
                {
                    while (reader.Read())
                        _connectionStringCache[PartitionCount] = MakeConnectionFromCurrentRow(reader);
                }
            }
        }
コード例 #12
0
 public ProductDeleteJob(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
コード例 #13
0
        void ExecuteAddNewPartition(int partition, DatabaseConnectionString connectionString, bool autoAssign)
        {
            using (var transaction = new TransactionScope(TransactionScopeOption.RequiresNew))
            using (var connection = _connectionStrings.PartitionMapConnectionString.CreateDbConnection())
            using (var command = connection.CreateCommand())
            {
                command.CommandText = "AddNewPartition";
                command.CommandType = CommandType.StoredProcedure;

                var p1 = command.CreateParameter();
                p1.ParameterName = "newPartition";
                p1.Direction = ParameterDirection.Input;
                p1.Value = partition;
                command.Parameters.Add(p1);

                var p2 = command.CreateParameter();
                p2.ParameterName = "providerName";
                p2.Direction = ParameterDirection.Input;
                if (connectionString.ProviderName == null)
                    p2.Value = DBNull.Value;
                else
                    p2.Value = connectionString.ProviderName;
                command.Parameters.Add(p2);

                var p3 = command.CreateParameter();
                p3.ParameterName = "connectionString";
                p3.Direction = ParameterDirection.Input;
                p3.Value = connectionString.ConnectionString;
                command.Parameters.Add(p3);

                var p4 = command.CreateParameter();
                p4.ParameterName = "autoAssign";
                p4.Direction = ParameterDirection.Input;
                p4.Value = autoAssign;
                command.Parameters.Add(p4);

                connection.Open();

                command.ExecuteNonQuery();

                transaction.Complete();
            }
        }
コード例 #14
0
 public ProductWriteRepository(DatabaseConnectionString connectionString, ICategoryWriteRepository categoryRepository)
 {
     _categoryRepository = categoryRepository;
     _connectionString   = connectionString.Value;
 }
コード例 #15
0
 public ConnectionStringMap(DatabaseConnectionString partitionMapConnectionString)
 {
     ConnectionStringCache = new ConcurrentDictionary<int, DatabaseConnectionString>();
     PartitionMapConnectionString = partitionMapConnectionString;
 }
コード例 #16
0
 public DatabaseService(IOptions <DatabaseConnectionString> connectionsStringOptions)
 {
     _connectionString = connectionsStringOptions.Value;
 }
コード例 #17
0
 public UserRepository(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
コード例 #18
0
 public DatabaseMigrator(
     DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString;
 }
コード例 #19
0
 public CartReadRepository(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
コード例 #20
0
 public DeleteImagesInFolder(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
コード例 #21
0
 /// <summary>
 /// Initializes an instance of the FederatedPartitionProvider class using provided values for federation and distribution names.
 /// </summary>
 /// <param name="federationRootConnectionString">Connection string to a federation root.</param>
 /// <param name="federationName">Federation name.</param>
 /// <param name="distributionName">Distribution name.</param>
 public FederatedPartitionProvider(DatabaseConnectionString federationRootConnectionString, string federationName, string distributionName)
 {
     DistributionName = distributionName;
     FederationName = federationName;
     FederationRootConnectionString = federationRootConnectionString;
 }
コード例 #22
0
 public DatabaseStockDummyFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("stocktest");
 }
コード例 #23
0
 /// <summary>
 /// Initializes an instance of the FederatedDatabaseConnection using the provided connection string and the statement that should be executed when connection is opened.
 /// </summary>
 /// <param name="connectionString">Connection string.</param>
 /// <param name="federationCommand">Command that will be executed when the connection is opened.</param>
 public FederatedDatabaseConnection(DatabaseConnectionString connectionString, FederationCommand federationCommand)
 {
     _connectionString = connectionString;
     FederationCommand = federationCommand;
 }
コード例 #24
0
 public StockDataAccessImplMySql()
 {
     this.dbConnectionString = DatabaseConnectionString.GetAzureConnectionString("stock");
 }
コード例 #25
0
 public DatabaseOrderDummyFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("ordertest");
 }
コード例 #26
0
 public DataAccessImplMySql()
 {
     this.dbConnectionString = DatabaseConnectionString.GetAzureConnectionString("product");
 }
コード例 #27
0
 public DatabaseLoginTestFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("logintest");
 }
コード例 #28
0
 public OrderDataAccessImplMySql()
 {
     this.dbConnectionString = DatabaseConnectionString.GetAzureConnectionString("order");
 }
コード例 #29
0
 public CategoryWriteRepository(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
コード例 #30
0
 public DatabaseProductDummyFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("producttest");
 }