WithDatabase() public method

Creates a copy of this connection string with the specified database instead of the current
public WithDatabase ( string databaseName ) : SqlConnectionString
databaseName string Name of the database.
return SqlConnectionString
Exemplo n.º 1
0
        public List<string> GetDatabases(SqlConnectionString connectionString)
        {
            var databases = new List<string>();

            using (var conn = new SqlConnection(connectionString.WithDatabase("master")))
            {
                conn.Open();
                var serverConnection = new ServerConnection(conn);
                var server = new Server(serverConnection);
                databases.AddRange(from Database database in server.Databases select database.Name);
            }

            return databases;
        }
Exemplo n.º 2
0
        public List <string> GetDatabases(SqlConnectionString connectionString)
        {
            var databases = new List <string>();

            using (var conn = new SqlConnection(connectionString.WithDatabase("master")))
            {
                conn.Open();
                var serverConnection = new ServerConnection(conn);
                var server           = new Server(serverConnection);
                databases.AddRange(from Database database in server.Databases select database.Name);
            }

            return(databases);
        }
Exemplo n.º 3
0
 public List<DatabaseTable> GetTables(SqlConnectionString connectionString)
 {
     using (var conn = new SqlConnection(connectionString.WithDatabase("master")))
     {
         conn.Open();
         var serverConnection = new ServerConnection(conn);
         var server = new Server(serverConnection);
         return
             server
             .Databases[connectionString.Database]
             .Tables
             .Cast<Table>()
             .Select(t => new DatabaseTable
                              {
                                  Name = t.Name,
                                  RowCount = t.RowCount
                              })
             .ToList();
     }
 }
Exemplo n.º 4
0
 public List <DatabaseTable> GetTables(SqlConnectionString connectionString)
 {
     using (var conn = new SqlConnection(connectionString.WithDatabase("master")))
     {
         conn.Open();
         var serverConnection = new ServerConnection(conn);
         var server           = new Server(serverConnection);
         return
             (server
              .Databases[connectionString.Database]
              .Tables
              .Cast <Table>()
              .Select(t => new DatabaseTable
         {
             Name = t.Name,
             RowCount = t.RowCount
         })
              .ToList());
     }
 }