Methods to retrieve SMO data and transform it into a POCO representation of BIML
Esempio n. 1
0
        public static Biml BuildBiml( BimlRequest request )
        {
            // Configure SQL SMO
            var server = new Server( request.ServerName );
            var scriptingOptions = new ScriptingOptions { Encoding = Encoding.UTF8 };
            server.Script( scriptingOptions );
            var database = new Microsoft.SqlServer.Management.Smo.Database( server, request.DatabaseName );
            database.Refresh();

            var bimlService = new BimlService();
            var output = new Biml();

            // Selectively build sections
            if ( request.HasConnections )
                output.Connections = bimlService.GetConnections( server, database );
            if ( request.HasDatabases )
                output.Databases = bimlService.GetDatabases( database );
            if( request.HasSchemas )
                output.Schemas = bimlService.GetSchemas( database );
            if (request.HasTables)
            {
                output.Tables = bimlService.GetTables( database, request.HasFactsAndDimensions );
            }
            if (request.HasFactsAndDimensions)
            {
                output.Facts = bimlService.GetFacts( database );
                output.Dimensions = bimlService.GetDimensions( database );
            }

            return output;
        }
Esempio n. 2
0
        public static Biml BuildBiml(BimlRequest request)
        {
            // Configure SQL SMO
            var server           = new Server(request.ServerName);
            var scriptingOptions = new ScriptingOptions {
                Encoding = Encoding.UTF8
            };

            server.Script(scriptingOptions);
            var database = new Microsoft.SqlServer.Management.Smo.Database(server, request.DatabaseName);

            database.Refresh();

            var bimlService = new BimlService();
            var output      = new Biml();

            // Selectively build sections
            if (request.HasConnections)
            {
                output.Connections = bimlService.GetConnections(server, database);
            }
            if (request.HasDatabases)
            {
                output.Databases = bimlService.GetDatabases(database);
            }
            if (request.HasSchemas)
            {
                output.Schemas = bimlService.GetSchemas(database);
            }
            if (request.HasTables)
            {
                output.Tables = bimlService.GetTables(database, request.HasFactsAndDimensions);
            }
            if (request.HasFactsAndDimensions)
            {
                output.Facts      = bimlService.GetFacts(database);
                output.Dimensions = bimlService.GetDimensions(database);
            }

            return(output);
        }