Skip to content

Commit

Permalink
Replacing a bad 'return' statement with 'continue'
Browse files Browse the repository at this point in the history
Fixes #7
  • Loading branch information
sliekens committed Jun 29, 2015
1 parent a396868 commit cc2e338
Showing 1 changed file with 94 additions and 90 deletions.
184 changes: 94 additions & 90 deletions src/Powerup/Application.cs
Original file line number Diff line number Diff line change
@@ -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<IQueryBase> _typesToFind;
List<SqlObject> _sqlObject = new List<SqlObject>();

public Application(Configuration conn)
{
this.conn = conn;
_typesToFind = new List<IQueryBase>
{
new ProcedureQuery(),
new FunctionQuery(),
new ViewQuery()
};

}

public IEnumerable<SqlObject> 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<IQueryBase> _typesToFind;
List<SqlObject> _sqlObject = new List<SqlObject>();

public Application(Configuration conn)
{
this.conn = conn;
_typesToFind = new List<IQueryBase>
{
new ProcedureQuery(),
new FunctionQuery(),
new ViewQuery()
};

}

public IEnumerable<SqlObject> 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();
}
}
}
}

}
}

0 comments on commit cc2e338

Please sign in to comment.