private List <string> LoadMetadata(MetadataType type)
        {
            var loadingOptions = new MetadataLoadingOptions
            {
                LoadDefaultDatabaseOnly = type != MetadataType.Database,
                LoadSystemObjects       = true
            };

            var container = new MetadataContainer(TemporaryMetadataContainer.SQLContext)
            {
                LoadingOptions = loadingOptions
            };

            var list = new MetadataList(container);

            list.Load(type, false);
            //list.Load(MetadataType.Database, false);

            //if (type == MetadataType.Schema)
            //{
            //    var defaultDb = list.Databases.FirstOrDefault(x => x.Default);
            //    if (defaultDb != null)
            //    {
            //        defaultDb.Items.Load(type, false);
            //        list = defaultDb.Items;
            //    }
            //}

            return(list.Select(x => x.Name).ToList());
        }
예제 #2
0
        } // createQueryBuilder(...)

        //
        internal void buildBindingList(bool loadDefaultDatabaseOnly, bool loadSystemObjects, bool withFields)
        {
            this._colQnBindingList = new BindingList <ColumnQN>();
            using (SQLContext sqlContext = new SQLContext())
            {
                sqlContext.Assign(this._qb.SQLContext);
                sqlContext.MetadataContainer.LoadingOptions.LoadDefaultDatabaseOnly = loadDefaultDatabaseOnly;
                sqlContext.MetadataContainer.LoadingOptions.LoadSystemObjects       = loadSystemObjects;

                using (MetadataList xList = new MetadataList(sqlContext.MetadataContainer))
                {
                    xList.Load(MetadataType.Server, false);
                    foreach (MetadataItem srv in xList)
                    {
                    }
                    xList.Load(MetadataType.Database, false);
                    foreach (MetadataItem db in xList)
                    {
                        using (MetadataList schemasList = new MetadataList(db))
                        {
                            schemasList.Load(MetadataType.Schema, false);
                            foreach (MetadataItem sch in schemasList)
                            {
                                using (MetadataList tablesList = new MetadataList(sch))
                                {
                                    tablesList.Load(MetadataType.Table, false);
                                    foreach (MetadataItem tbl in tablesList)
                                    {
                                        using (MetadataList columnsList = new MetadataList(tbl))
                                        {
                                            columnsList.Load(MetadataType.Field, false);

                                            foreach (MetadataItem col in columnsList)
                                            {
                                                MetadataItem mdi = col;
                                                this.TreatField(mdi);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        } // buildBindingList(...)
        private void LoadDatabaseList()
        {
            DefaultDatabase = null;
            _databases      = null;

            if (Connection.MetadataProvider != null && Connection.SyntaxProvider.IsSupportDatabases())
            {
                _temporarySqlContext.MetadataProvider = Connection.MetadataProvider;
                _temporarySqlContext.SyntaxProvider   = Connection.SyntaxProvider;

                MetadataLoadingOptions oldOptions = new MetadataLoadingOptions();
                oldOptions.Assign(TemporaryMetadataContainer.LoadingOptions);

                MetadataLoadingOptions tempOptions = new MetadataLoadingOptions
                {
                    LoadDefaultDatabaseOnly = false,
                    LoadSystemObjects       = true
                };

                try
                {
                    TemporaryMetadataContainer.LoadingOptions = tempOptions;
                    MetadataList list = new MetadataList(TemporaryMetadataContainer);
                    list.Load(MetadataType.Database, false);
                    _databases = list.Databases;
                }
                finally
                {
                    TemporaryMetadataContainer.LoadingOptions = oldOptions;
                    tempOptions.Dispose();
                }
            }

            _wizardPageLoadOpts.ChecklistDatabases.Items.Clear();

            if (_databases == null)
            {
                return;
            }

            foreach (MetadataNamespace database in _databases)
            {
                if (database.Default)
                {
                    DefaultDatabase = database.Name;
                }

                _wizardPageLoadOpts.ChecklistDatabases.Items.Add(new DatabaseObjectForListbox(database.Name, database.Default));
            }
        }
        private List <string> LoadMetadata(MetadataType type)
        {
            var loadingOptions = new MetadataLoadingOptions
            {
                LoadDefaultDatabaseOnly = type != MetadataType.Database,
                LoadSystemObjects       = true
            };

            var container = new MetadataContainer(TemporaryMetadataContainer.SQLContext)
            {
                LoadingOptions = loadingOptions
            };

            var list = new MetadataList(container);

            list.Load(type, false);
            return(list.Select(x => x.Name).ToList());
        }