Skip to content

Commit 3d8f92b

Browse files
author
James Craig
committed
Slight change to the namespace to make it a bit nicer to work with.
Change in the constructor so that DbProviderFactory isn't required. If skipped it defaults to SqlClientFactory.Instance. Added SQLHelper to Canister so that it's registered.
1 parent 7919ce5 commit 3d8f92b

File tree

7 files changed

+37
-8
lines changed

7 files changed

+37
-8
lines changed

SQLHelper.SpeedTests/Tests/AddQuery.cs

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

7-
namespace SQLHelper.SpeedTests.Tests
7+
namespace SQLHelperDB.SpeedTests.Tests
88
{
99
[Series("AddQuery", 100, "Console")]
1010
public class AddQuery : ITimedTask
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Canister.Interfaces;
2+
using Microsoft.Extensions.DependencyInjection;
3+
4+
namespace SQLHelperDB.CanisterModules
5+
{
6+
/// <summary>
7+
/// SQLHelper Canister module.
8+
/// </summary>
9+
/// <seealso cref="IModule"/>
10+
public class SQLHelperModule : IModule
11+
{
12+
/// <summary>
13+
/// Order to run this in
14+
/// </summary>
15+
public int Order => 1;
16+
17+
/// <summary>
18+
/// Loads the module using the bootstrapper
19+
/// </summary>
20+
/// <param name="bootstrapper">The bootstrapper.</param>
21+
public void Load(IBootstrapper bootstrapper)
22+
{
23+
if (bootstrapper == null)
24+
return;
25+
bootstrapper.Register<SQLHelper>(ServiceLifetime.Transient);
26+
}
27+
}
28+
}

src/SQLHelper.DB/HelperClasses/Command.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ limitations under the License.
1515
*/
1616

1717
using BigBook;
18-
using SQLHelper.DB.HelperClasses;
1918
using SQLHelper.HelperClasses.Interfaces;
19+
using SQLHelperDB.HelperClasses;
2020
using System;
2121
using System.Collections.Generic;
2222
using System.Data;

src/SQLHelper.DB/HelperClasses/SelectFinder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ limitations under the License.
1717
using Antlr4.Runtime.Misc;
1818
using SQLParser.Parsers.TSql;
1919

20-
namespace SQLHelper.DB.HelperClasses
20+
namespace SQLHelperDB.HelperClasses
2121
{
2222
/// <summary>
2323
/// Finds selects within SQL code.

src/SQLHelper.DB/SQLHelper.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ limitations under the License.
2222
using System.Collections.Generic;
2323
using System.Data;
2424
using System.Data.Common;
25+
using System.Data.SqlClient;
2526
using System.Linq;
2627
using System.Threading.Tasks;
2728

28-
namespace SQLHelper
29+
namespace SQLHelperDB
2930
{
3031
/// <summary>
3132
/// SQL helper class
@@ -38,8 +39,8 @@ public class SQLHelper
3839
/// <param name="configuration">The configuration object.</param>
3940
/// <param name="factory">The factory.</param>
4041
/// <param name="database">The database.</param>
41-
public SQLHelper(IConfiguration configuration, DbProviderFactory factory, string database = "Default")
42-
: this(new Connection(configuration, factory, database))
42+
public SQLHelper(IConfiguration configuration, DbProviderFactory factory = null, string database = "Default")
43+
: this(new Connection(configuration, factory ?? SqlClientFactory.Instance, database))
4344
{
4445
}
4546

test/SQLHelper.Tests/SQLHelperAsyncTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using System.Threading.Tasks;
1010
using Xunit;
1111

12-
namespace SQLHelper.Tests
12+
namespace SQLHelperDB.Tests
1313
{
1414
public class SQLHelperAsyncTests : TestingDirectoryFixture
1515
{

test/SQLHelper.Tests/SQLHelperTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using System.Text;
1010
using Xunit;
1111

12-
namespace SQLHelper.Tests
12+
namespace SQLHelperDB.Tests
1313
{
1414
public class SQLHelperTests : TestingDirectoryFixture
1515
{

0 commit comments

Comments
 (0)