//////////////////////////////////////////////////////////////////////////
        /// 1st way:
        /// This method demonstrates the direct access to the internal metadata
        /// objects collection (MetadataContainer).
        //////////////////////////////////////////////////////////////////////////
        public void Way1(object sender, EventArgs e)
        {
            ActiveTabs = 0;

            var queryBuilder1 = QueryBuilderStore.Get("LoadMetadata");

            ResetQueryBuilderMetadata(queryBuilder1);
            queryBuilder1.SyntaxProvider = new GenericSyntaxProvider();
            // prevent QueryBuilder to request metadata
            queryBuilder1.MetadataLoadingOptions.OfflineMode = true;

            queryBuilder1.MetadataProvider = null;

            MetadataContainer metadataContainer = queryBuilder1.MetadataContainer;

            metadataContainer.BeginUpdate();

            try
            {
                metadataContainer.Clear();

                MetadataNamespace schemaDbo = metadataContainer.AddSchema("dbo");

                // prepare metadata for table "Orders"
                MetadataObject orders = schemaDbo.AddTable("Orders");
                // fields
                orders.AddField("OrderId");
                orders.AddField("CustomerId");

                // prepare metadata for table "Order Details"
                MetadataObject orderDetails = schemaDbo.AddTable("Order Details");
                // fields
                orderDetails.AddField("OrderId");
                orderDetails.AddField("ProductId");
                // foreign keys
                MetadataForeignKey foreignKey = orderDetails.AddForeignKey("OrderDetailsToOrders");

                using (MetadataQualifiedName referencedName = new MetadataQualifiedName())
                {
                    referencedName.Add("Orders");
                    referencedName.Add("dbo");

                    foreignKey.ReferencedObjectName = referencedName;
                }

                foreignKey.Fields.Add("OrderId");
                foreignKey.ReferencedFields.Add("OrderId");
            }
            finally
            {
                metadataContainer.EndUpdate();
            }

            queryBuilder1.MetadataStructure.Refresh();
        }
        //////////////////////////////////////////////////////////////////////////
        /// 1st way:
        /// This method demonstrates the direct access to the internal metadata
        /// objects collection (MetadataContainer).
        //////////////////////////////////////////////////////////////////////////
        private void btn1Way_Click(object sender, EventArgs e)
        {
            // prevent QueryBuilder to request metadata
            QBuilder.MetadataLoadingOptions.OfflineMode = true;

            QBuilder.MetadataProvider = null;

            MetadataContainer metadataContainer = QBuilder.MetadataContainer;

            metadataContainer.BeginUpdate();

            try
            {
                metadataContainer.Clear();

                MetadataNamespace schemaDbo = metadataContainer.AddSchema("dbo");

                // prepare metadata for table "Orders"
                MetadataObject orders = schemaDbo.AddTable("Orders");
                // fields
                orders.AddField("OrderId");
                orders.AddField("CustomerId");

                // prepare metadata for table "Order Details"
                MetadataObject orderDetails = schemaDbo.AddTable("Order Details");
                // fields
                orderDetails.AddField("OrderId");
                orderDetails.AddField("ProductId");
                // foreign keys
                MetadataForeignKey foreignKey = orderDetails.AddForeignKey("OrderDetailsToOrders");

                using (MetadataQualifiedName referencedName = new MetadataQualifiedName())
                {
                    referencedName.Add("Orders");
                    referencedName.Add("dbo");

                    foreignKey.ReferencedObjectName = referencedName;
                }

                foreignKey.Fields.Add("OrderId");
                foreignKey.ReferencedFields.Add("OrderId");
            }
            finally
            {
                metadataContainer.EndUpdate();
            }

            QBuilder.InitializeDatabaseSchemaTree();
        }