From cc2e3380f32b887aac8b608705d326f42738a7e6 Mon Sep 17 00:00:00 2001 From: Steven Liekens Date: Mon, 29 Jun 2015 16:07:47 +0200 Subject: [PATCH] Replacing a bad 'return' statement with 'continue' Fixes #7 --- src/Powerup/Application.cs | 184 +++++++++++++++++++------------------ 1 file changed, 94 insertions(+), 90 deletions(-) diff --git a/src/Powerup/Application.cs b/src/Powerup/Application.cs index d69edc9..a44a086 100644 --- a/src/Powerup/Application.cs +++ b/src/Powerup/Application.cs @@ -1,93 +1,97 @@ -using System; -using System.Collections.Generic; -using System.Data.SqlClient; -using Powerup.SqlObjects; -using Powerup.SqlQueries; - -namespace Powerup -{ - public class Application - { - Configuration conn; - - readonly List _typesToFind; - List _sqlObject = new List(); - - public Application(Configuration conn) - { - this.conn = conn; - _typesToFind = new List - { - new ProcedureQuery(), - new FunctionQuery(), - new ViewQuery() - }; - - } - - public IEnumerable TheObjects() - { - return _sqlObject; - } - - public void BuildEntities() +using System; +using System.Collections.Generic; +using System.Data.SqlClient; +using Powerup.SqlObjects; +using Powerup.SqlQueries; + +namespace Powerup +{ + public class Application + { + Configuration conn; + + readonly List _typesToFind; + List _sqlObject = new List(); + + public Application(Configuration conn) + { + this.conn = conn; + _typesToFind = new List + { + new ProcedureQuery(), + new FunctionQuery(), + new ViewQuery() + }; + + } + + public IEnumerable TheObjects() + { + return _sqlObject; + } + + public void BuildEntities() { Console.WriteLine(conn.ConnectionStringBuilder.ConnectionString); - using (var con = conn.ConnectionStringBuilder.CreateConnection()) - { - con.Open(); - foreach (var type in _typesToFind) - { - using (var cmd = new SqlCommand(type.NameSql, con)) - { - using (var reader = cmd.ExecuteReader()) - { - if (!reader.HasRows) return; - while (reader.Read()) - { - _sqlObject.Add(type.MakeSqlObject(con.Database, - reader[1].ToString(), - reader[0].ToString(), - (int) reader[2])); - } - } - } - } - } - - } - - public void AddCodeToEntities() - { - AddCodeToObject(); - } - - public void WriteOutPut() - { - - } - - private void AddCodeToObject() - { - foreach (var sqlObject in _sqlObject) - { - using (var con = conn.ConnectionStringBuilder.CreateConnection()) - using (var cmd = new SqlCommand(sqlObject.Query, con)) - { - cmd.Parameters.Add(new SqlParameter("@1", sqlObject.ObjectId)); - con.Open(); - using (var reader = cmd.ExecuteReader()) - { - if (!reader.HasRows) return; - while (reader.Read()) - { - sqlObject.Code += reader[0].ToString(); - } - sqlObject.AddCodeTemplate(); - } - } - } - } - - } + using (var con = conn.ConnectionStringBuilder.CreateConnection()) + { + con.Open(); + foreach (var type in _typesToFind) + { + using (var cmd = new SqlCommand(type.NameSql, con)) + { + using (var reader = cmd.ExecuteReader()) + { + if (!reader.HasRows) return; + while (reader.Read()) + { + _sqlObject.Add(type.MakeSqlObject(con.Database, + reader[1].ToString(), + reader[0].ToString(), + (int) reader[2])); + } + } + } + } + } + + } + + public void AddCodeToEntities() + { + AddCodeToObject(); + } + + public void WriteOutPut() + { + + } + + private void AddCodeToObject() + { + foreach (var sqlObject in _sqlObject) + { + using (var con = conn.ConnectionStringBuilder.CreateConnection()) + using (var cmd = new SqlCommand(sqlObject.Query, con)) + { + cmd.Parameters.Add(new SqlParameter("@1", sqlObject.ObjectId)); + con.Open(); + using (var reader = cmd.ExecuteReader()) + { + if (!reader.HasRows) + { + continue; + } + + while (reader.Read()) + { + sqlObject.Code += reader[0].ToString(); + } + sqlObject.AddCodeTemplate(); + } + } + } + } + + } } \ No newline at end of file