/// <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);
        }
        /// <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);
        }
        /// <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");
            }
        }
        /// <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);
            }
        }
        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;
 }
        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();
            }
        }
 public ProductWriteRepository(DatabaseConnectionString connectionString, ICategoryWriteRepository categoryRepository)
 {
     _categoryRepository = categoryRepository;
     _connectionString   = connectionString.Value;
 }
 public ConnectionStringMap(DatabaseConnectionString partitionMapConnectionString)
 {
     ConnectionStringCache = new ConcurrentDictionary<int, DatabaseConnectionString>();
     PartitionMapConnectionString = partitionMapConnectionString;
 }
 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;
 }
 public CartReadRepository(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
 public DeleteImagesInFolder(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
 /// <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;
 }
 public DatabaseStockDummyFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("stocktest");
 }
 /// <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");
 }
 public OrderDataAccessImplMySql()
 {
     this.dbConnectionString = DatabaseConnectionString.GetAzureConnectionString("order");
 }
示例#29
0
 public CategoryWriteRepository(DatabaseConnectionString connectionString)
 {
     _connectionString = connectionString.Value;
 }
 public DatabaseProductDummyFiller()
 {
     connectionString = DatabaseConnectionString.GetAzureConnectionString("producttest");
 }