Exemple #1
0
        public RelationalDatabaseDataSet FindTablesBy(CatalogName[] catalogNameCollection)
        {
            Guard.Against.NullOrEmptyCollection(catalogNameCollection, nameof(catalogNameCollection));

            RelationalDatabaseDataSet ds = new RelationalDatabaseDataSet();

            ds.EnforceConstraints = false;

            Dsl.ConnectToMsSqlServer()
            .UsingThisConnectionString(_connection.ConnectionString)
            .ForEachCatalog(CatalogName.ToArray(catalogNameCollection))
            .SelectAllColumns()
            .From(TableStatements.From)
            .Adapt()
            .UsingThisMapping(BuildTableMapping(ds))
            .FillDataset(ds)
            ;

            /*using (SqlDataAdapter adapter = new SqlDataAdapter(TableStatments.SELECT_ALL_TABLES, Connection))
             * {
             *  adapter.TableMappings.Add(CreateTableMapping(RdmsDataSet.SchemaStructure.Table.TableName));
             *
             *  foreach (string catalog in catalogs)
             *  {
             *      Connection.ChangeDatabase(catalog);
             *
             *      adapter.Fill(ds);
             *  }
             * }*/

            return(ds);
        }
Exemple #2
0
        public RelationalDatabaseDataSet FindTablesBy(CatalogName catalog, TableName[] tableNameCollection)
        {
            RelationalDatabaseDataSet ds = new RelationalDatabaseDataSet();

            ds.EnforceConstraints = false;

            Dsl.ConnectToMsSqlServer()
            .UsingThisConnectionString(_connection.ConnectionString)
            .ForThisCatalog(catalog.Name)
            .SelectAllColumns()
            .From(TableStatements.From)
            .Where("TABLE_NAME").In(TableName.ToArray(tableNameCollection))
            .Adapt().UsingThisMapping(BuildTableMapping(ds))
            .FillDataset(ds);

            return(ds);
        }
Exemple #3
0
        public void FillColumnsBy(RelationalDatabaseDataSet dataSet, CatalogName[] catalogNameCollection)
        {
            var dsl = Dsl.ConnectToMsSqlServer().UsingThisConnectionString(_context.ConnectionString);

            dsl.ForEachCatalog(catalogNameCollection.Select(c => c.Name).ToArray())
            .SelectAllColumns()
            .From(ColumnStatements.FromStatement)
            //.Where("TABLE_CATALOG").IsEqualTo(catalogName)
            //.And("TABLE_NAME").In(tableNameCollection)
            .OrderBy("TABLE_CATALOG")
            .ThenBy("TABLE_SCHEMA").Asc()
            .ThenBy("TABLE_NAME").Asc()
            .ThenBy("ORDINAL_POSITION").Asc()
            .Adapt()
            .UsingThisMapping(BuildTableMapping(dataSet))
            .FillDataset(dataSet);
        }
Exemple #4
0
        public void FillDomainsBy(RelationalDatabaseDataSet dataSet, CatalogName[] catalogNameCollection)
        {
            foreach (var catalog in catalogNameCollection)
            {
                Dsl.ConnectToMsSqlServer().UsingThisConnectionString(_context.ConnectionString)
                .ForThisCatalog(catalog)
                .SelectAllColumns()
                .From(DomainStatements.FromStatement)
                .Where("DOMAIN_SCHEMA").IsNotEqualTo("sys")
                .OrderBy("DOMAIN_SCHEMA").Asc().ThenBy("DOMAIN_NAME").Asc()
                .Adapt().UsingThisMapping(BuildTableMapping(dataSet))
                .FillDataset(dataSet);
            }

            Dsl.ConnectToMsSqlServer().UsingThisConnectionString(_context.ConnectionString)
            .ForThisCatalog(catalogNameCollection.First())
            .SelectAllColumns()
            .From(DomainStatements.FromStatement)
            .Where("DOMAIN_SCHEMA").IsEqualTo("sys")
            .OrderBy("DOMAIN_SCHEMA").Asc().ThenBy("DOMAIN_NAME").Asc()
            .Adapt().UsingThisMapping(BuildTableMapping(dataSet))
            .FillDataset(dataSet);
        }