Example #1
0
        public override void LoadObjects(MetadataList objects, MetadataLoadingOptions loadingOptions)
        {
            if (!Connected)
            {
                Connect();
            }

            try
            {
                // load tables
                DataTable schemaTable = _connection.GetSchema("Tables");

                MetadataObjectFetcherFromDatatable mof = new MetadataObjectFetcherFromDatatable(objects, loadingOptions);
                mof.NameFieldName   = "TABLE_NAME";
                mof.TypeFieldName   = "TABLE_TYPE";
                mof.TableType       = new string[] { "TABLE" };
                mof.SystemTableType = new string[] { "SYSTEM TABLE" };
                mof.Datatable       = schemaTable;

                mof.LoadMetadata();

                // load views
                schemaTable = _connection.GetSchema("Views");

                mof = new MetadataObjectFetcherFromDatatable(objects, loadingOptions);

                mof.NameFieldName     = "TABLE_NAME";
                mof.DefaultObjectType = MetadataType.View;
                mof.Datatable         = schemaTable;

                mof.LoadMetadata();
            }
            catch (Exception exception)
            {
                throw new QueryBuilderException(exception.Message, exception);
            }
        }