Exemple #1
0
        public void Generate(string name, string tableName, Column[] columns, Parameter[] prms, Column[] filterColumns, Parameter[] filterPrms)
        {
            // Parameter-column equations list
            var eqTempl = new ColumnTemplate();

            eqTempl.GenerateColumnParametrEquation(columns, prms, 2);
            var equation = eqTempl.TransformText().TrimEnd();

            // List of procedure input parameter descriptions
            var allParams = new Parameter[prms.Length + filterPrms.Length];

            Array.Copy(filterPrms, 0, allParams, 0, filterPrms.Length);
            Array.Copy(prms, 0, allParams, filterPrms.Length, prms.Length);
            var prmDescTempl = new ColumnTemplate();

            prmDescTempl.GenerateParameters(allParams, 1);
            var parameters = prmDescTempl.TransformText().TrimEnd();

            // Filter condition
            var filter = "";

            if (filterColumns != null && filterPrms != null)
            {
                var filterTempl = new ColumnTemplate();
                filterTempl.GenerateColumnParametrEquation(filterColumns, filterPrms, 2, false);
                filter = "    WHERE\n" + filterTempl.TransformText().TrimEnd();
            }


        #line default
        #line hidden

        #line 28 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("-- UPDATE ");


        #line default
        #line hidden

        #line 29 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 29 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("\r\nCREATE OR REPLACE PROCEDURE ");


        #line default
        #line hidden

        #line 30 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(name));


        #line default
        #line hidden

        #line 30 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("\r\n(\r\n");


        #line default
        #line hidden

        #line 32 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(parameters));


        #line default
        #line hidden

        #line 32 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("\r\n)\r\nLANGUAGE \'sql\'\r\nAS\r\n$BODY$\r\n    UPDATE ");


        #line default
        #line hidden

        #line 37 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 37 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("\r\n    SET\r\n");


        #line default
        #line hidden

        #line 39 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(equation));


        #line default
        #line hidden

        #line 39 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write("\r\n");


        #line default
        #line hidden

        #line 40 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(filter));


        #line default
        #line hidden

        #line 40 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
            this.Write(";\r\n$BODY$;\r\n");


        #line default
        #line hidden

        #line 42 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\PostgreSQL\ModifyProcedureTemplate .tt"
        }
Exemple #2
0
        public void Generate(string name, string tableName, Column[] columns, Parameter[] prms)
        {
            // List of table columns
            var colTempl = new ColumnTemplate();

            colTempl.GenerateWithoutType(columns, 2);
            var tableColumns = colTempl.TransformText().TrimEnd();

            // List of rpocedure params
            var prmTempl = new ColumnTemplate();

            prmTempl.GenerateWithoutType(prms, 2);
            var paramList = prmTempl.TransformText().TrimEnd();

            // List of procedure input param descriptions
            var prmDescTempl = new ColumnTemplate();

            prmDescTempl.GenerateParameters(prms, 1);
            var procParams = prmDescTempl.TransformText().TrimEnd();


        #line default
        #line hidden

        #line 22 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("-- INSERT INTO ");


        #line default
        #line hidden

        #line 23 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 23 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\nCREATE OR REPLACE PROCEDURE ");


        #line default
        #line hidden

        #line 24 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(name));


        #line default
        #line hidden

        #line 24 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\n(\r\n");


        #line default
        #line hidden

        #line 26 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(procParams));


        #line default
        #line hidden

        #line 26 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\n)\r\nLANGUAGE \'sql\'\r\nAS\r\n$BODY$\r\n    INSERT INTO ");


        #line default
        #line hidden

        #line 31 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 31 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\n    (\r\n");


        #line default
        #line hidden

        #line 33 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableColumns));


        #line default
        #line hidden

        #line 33 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\n    )\r\n    VALUES\r\n    (\r\n");


        #line default
        #line hidden

        #line 37 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(paramList));


        #line default
        #line hidden

        #line 37 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
            this.Write("\r\n    );\r\n$BODY$;\r\n");


        #line default
        #line hidden

        #line 40 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\AddProcedureTemplate.tt"
        }
        public void Generate(string name, string tableName, Column[] filterColumns, Parameter[] filterPrms)
        {
            // Filter condition
            var filter = "";

            if (filterColumns != null && filterPrms != null)
            {
                var filterTempl = new ColumnTemplate();
                filterTempl.GenerateColumnParametrEquation(filterColumns, filterPrms, 2, false);
                filter = "    WHERE\n" + filterTempl.TransformText().TrimEnd();
            }

            // List of procedure input parameter descriptions
            var paramsDescTempl = new ColumnTemplate();

            paramsDescTempl.GenerateParameters(filterPrms, 1);
            var paramsDesc = paramsDescTempl.TransformText().TrimEnd();


        #line default
        #line hidden

        #line 20 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write("-- DELETE FROM ");


        #line default
        #line hidden

        #line 21 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 21 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write("\r\nCREATE OR REPLACE PROCEDURE ");


        #line default
        #line hidden

        #line 22 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(name));


        #line default
        #line hidden

        #line 22 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write("\r\n(\r\n");


        #line default
        #line hidden

        #line 24 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(paramsDesc));


        #line default
        #line hidden

        #line 24 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write("\r\n)\r\nLANGUAGE \'sql\'\r\nAS\r\n$BODY$\r\n    DELETE FROM ");


        #line default
        #line hidden

        #line 29 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(tableName));


        #line default
        #line hidden

        #line 29 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write("\r\n");


        #line default
        #line hidden

        #line 30 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(this.ToStringHelper.ToStringWithCulture(filter));


        #line default
        #line hidden

        #line 30 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
            this.Write(";\r\n$BODY$;\r\n");


        #line default
        #line hidden

        #line 32 "C:\Users\admin\source\repos\DatabaseUtils\DatabaseScriptGenerator\Templates\Oracle\RemoveProcedureTemplate.tt"
        }