Beispiel #1
0
        public void BuildProcedureCode(DatabaseSchema databaseSchema, DatabaseStoredProcedure databaseStoredProcedure)
        {
            try
            {
                //grab the data
                if (databaseStoredProcedure.ResultSets.Count == 0)
                {
                    //Delete sprocs won't have resultsets, so will get called multiple times
                    var sprocRunner = new DatabaseSchemaReader.Procedures.ResultSetReader(databaseSchema);
                    sprocRunner.ExecuteProcedure(databaseStoredProcedure);
                }

                //write it
                var sprocWriter = new ProcedureWriter(databaseStoredProcedure, "Domain");
                var txt         = sprocWriter.Write();

                Clipboard.SetText(txt, TextDataFormat.UnicodeText);
            }
            catch (Exception exception)
            {
                Clipboard.SetText("//sorry, not available - " + exception.Message,
                                  TextDataFormat.UnicodeText);
                Debug.WriteLine(exception.Message);
            }
        }
        public static string GenerateStoredProcedure(DatabaseStoredProcedure proc)
        {
            if (_procedureTemplate == null)
            {
                _procedureTemplate = ReadTemplate("storedProcedure");
            }
            var builder     = new StringBuilder(_procedureTemplate);
            var sprocRunner = new DatabaseSchemaReader.Procedures.ResultSetReader(proc.DatabaseSchema);

            sprocRunner.ExecuteProcedure(proc);
            var resultsets     = proc.ResultSets;
            var propertyString = "";

            if (resultsets.Count <= 0)
            {
                return(builder.Replace("$name$", proc.Name)
                       .Replace("$properties$", propertyString).ToString());
            }
            var properties = proc.ResultSets.First().Columns.Select(GenerateAutoPropertySp).ToList();

            propertyString = properties.Aggregate((c, n) => c + n);
            return(builder.Replace("$name$", proc.Name)
                   .Replace("$properties$", propertyString).ToString());
        }
Beispiel #3
0
        public void BuildProcedureCode(DatabaseSchema databaseSchema, DatabaseStoredProcedure databaseStoredProcedure)
        {
            try
            {
                //grab the data
                if (databaseStoredProcedure.ResultSets.Count == 0)
                {
                    //Delete sprocs won't have resultsets, so will get called multiple times
                    var sprocRunner = new DatabaseSchemaReader.Procedures.ResultSetReader(databaseSchema);
                    sprocRunner.ExecuteProcedure(databaseStoredProcedure);
                }

                //write it
                var sprocWriter = new ProcedureWriter(databaseStoredProcedure, "Domain");
                var txt = sprocWriter.Write();

                Clipboard.SetText(txt, TextDataFormat.UnicodeText);
            }
            catch (Exception exception)
            {
                Clipboard.SetText("//sorry, not available - " + exception.Message,
                    TextDataFormat.UnicodeText);
                Debug.WriteLine(exception.Message);
            }
        }