Skip to content

Commit 5332e01

Browse files
authored
Merge pull request #1 from mourier/feature/simplified-interface
Feature/simplified interface
2 parents cc4f8fa + 5e5753f commit 5332e01

5 files changed

Lines changed: 760 additions & 11 deletions

File tree

src/GenericSQLEntityHandler/Enums.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Threading.Tasks;
66

7-
namespace GenericSQLEntityHandler
7+
namespace EntityHandler
88
{
99
public enum SaveType
1010
{

src/GenericSQLEntityHandler/GenericSQLEntityHandler.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
using System.Threading;
99

1010

11-
namespace GenericSQLEntityHandler
11+
namespace EntityHandler
1212
{
1313
public class GenericSQLEntityHandler
1414
{
@@ -21,7 +21,7 @@ public class GenericSQLEntityHandler
2121
private string reconnectSqlConnectionString = "";
2222

2323
private SqlTransaction sqlTransaction = null;
24-
private SqlConnection sqlConnection = null;
24+
2525

2626
private Dictionary<Type, Dictionary<string, string>> columnInformationList = new Dictionary<Type, Dictionary<string, string>>();
2727

@@ -103,7 +103,7 @@ public bool BulkSave<T>(ICollection<T> entities, string tableName, string[] colu
103103

104104

105105
SqlCommand cmd = GetSqlCommand();
106-
SqlBulkCopy copy = new SqlBulkCopy(sqlConnection, update || identity ? SqlBulkCopyOptions.KeepIdentity : SqlBulkCopyOptions.Default, sqlTransaction);
106+
SqlBulkCopy copy = new SqlBulkCopy(SqlConnection, update || identity ? SqlBulkCopyOptions.KeepIdentity : SqlBulkCopyOptions.Default, sqlTransaction);
107107
copy.BulkCopyTimeout = bulkCopyTimeout;
108108

109109
try
@@ -1191,9 +1191,9 @@ private SqlCommand GetSqlCommand()
11911191
{
11921192
SqlCommand sqlCommand;
11931193
if (sqlTransaction != null && sqlTransaction.Connection != null)
1194-
sqlCommand = new SqlCommand("", sqlConnection, sqlTransaction);
1194+
sqlCommand = new SqlCommand("", SqlConnection, sqlTransaction);
11951195
else
1196-
sqlCommand = new SqlCommand("", sqlConnection);
1196+
sqlCommand = new SqlCommand("", SqlConnection);
11971197

11981198
sqlCommand.CommandTimeout = timeOut;
11991199
TryConnectToDatabase(sqlCommand);
@@ -1222,9 +1222,9 @@ private void TryConnectToDatabase(SqlCommand sqlCommand)
12221222
if (string.IsNullOrEmpty(reconnectSqlConnectionString))
12231223
throw new Exception("Unable to connect to database.");
12241224

1225-
sqlConnection = new SqlConnection(reconnectSqlConnectionString);
1226-
sqlConnection.Open();
1227-
sqlCommand.Connection = sqlConnection;
1225+
SqlConnection = new SqlConnection(reconnectSqlConnectionString);
1226+
SqlConnection.Open();
1227+
sqlCommand.Connection = SqlConnection;
12281228
Thread.Sleep(1000);
12291229
}
12301230
}
@@ -1278,7 +1278,7 @@ private void AddParameterToCmd(object fieldObj, SqlCommand cmd, string idColumn)
12781278

12791279
public bool CreateTableClone(string sourceTableName, string newName, Type entityType)
12801280
{
1281-
SQLTableCreator creator = new SQLTableCreator(sqlConnection, sqlTransaction);
1281+
SQLTableCreator creator = new SQLTableCreator(SqlConnection, sqlTransaction);
12821282
SqlCommand cmd = GetSqlCommand();
12831283

12841284
cmd.CommandText = "SELECT TOP 1 * FROM [" + sourceTableName + "]";

src/GenericSQLEntityHandler/GenericSQLEntityHandler.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<Compile Include="Enums.cs" />
4444
<Compile Include="GenericSQLEntityHandler.cs" />
4545
<Compile Include="Properties\AssemblyInfo.cs" />
46+
<Compile Include="GenericSQLHandler.cs" />
4647
<Compile Include="SQLTableCreator.cs" />
4748
</ItemGroup>
4849
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

0 commit comments

Comments
 (0)