Exemplo n.º 1
0
 private void Apply(App.Common.Configurations.ConnectionStringElement connectionString)
 {
     this.Name     = connectionString.Name;
     this.Database = connectionString.Database;
     this.Server   = connectionString.Server;
     this.Port     = connectionString.Port;
     this.UserName = connectionString.UserName;
     this.Password = connectionString.Password;
     this.DbType   = connectionString.DbType;
 }
Exemplo n.º 2
0
 public ConnectionString(DatabaseType dbType, string connectionName = "")
 {
     System.Console.WriteLine(Configurations.Configuration.Current.Databases.Count);
     App.Common.Configurations.ConnectionStringElement connectionString = Configurations.Configuration.Current.Databases.ToList().Where(item => item.DbType == dbType && ((string.IsNullOrWhiteSpace(connectionName) && item.IsDefault) || item.Name == connectionName)).FirstOrDefault();
     if (string.IsNullOrWhiteSpace(connectionName) && connectionString == null)
     {
         throw new App.Common.Validation.ValidationException("CommonMessage.ConnectionStringNoDefaultItem");
     }
     if (!string.IsNullOrWhiteSpace(connectionName) && connectionString == null)
     {
         throw new App.Common.Validation.ValidationException("CommonMessage.ConnectionStringInvalidName", connectionName);
     }
     Apply(connectionString);
 }