@@ -15,7 +15,6 @@ limitations under the License.
15
15
*/
16
16
17
17
using BigBook ;
18
- using BigBook . DataMapper ;
19
18
using Microsoft . Extensions . Configuration ;
20
19
using Microsoft . Extensions . ObjectPool ;
21
20
using SQLHelperDB . HelperClasses ;
@@ -40,46 +39,15 @@ public class SQLHelper
40
39
/// <summary>
41
40
/// Initializes a new instance of the <see cref="SQLHelper"/> class.
42
41
/// </summary>
43
- /// <param name="configuration">The configuration object.</param>
44
- /// <param name="factory">The factory.</param>
45
- /// <param name="database">The database.</param>
46
- /// <param name="stringBuilderPool">
47
- /// The string builder pool (if passed in, this will be used to generate any StringBuilders
48
- /// the system needs).
49
- /// </param>
50
- /// <param name="aopManager">
51
- /// The aop manager (if passed in, this will be used to create new objects).
52
- /// </param>
53
- /// <param name="dataMapper">
54
- /// The data mapper (if passed in the data mapper is used to allow mapping between the
55
- /// dynamic objects that are returned and the class specified)
56
- /// </param>
57
- public SQLHelper ( IConfiguration configuration , DbProviderFactory ? factory = null , string database = "Default" , ObjectPool < StringBuilder > ? stringBuilderPool = null , Aspectus . Aspectus ? aopManager = null , Manager ? dataMapper = null )
58
- : this ( Connections . ContainsKey ( database ) ? Connections [ database ] : new Connection ( configuration , factory ?? SqlClientFactory . Instance , database ) , stringBuilderPool , aopManager , dataMapper )
59
- {
60
- }
61
-
62
- /// <summary>
63
- /// Initializes a new instance of the <see cref="SQLHelper"/> class.
64
- /// </summary>
65
- /// <param name="connection">The connection to use.</param>
66
- /// <param name="stringBuilderPool">
67
- /// The string builder pool (if passed in, this will be used to generate any StringBuilders
68
- /// the system needs).
69
- /// </param>
70
- /// <param name="aopManager">
71
- /// The aop manager (if passed in, this will be used to create new objects).
72
- /// </param>
73
- /// <param name="dataMapper">
74
- /// The data mapper (if passed in the data mapper is used to allow mapping between the
75
- /// dynamic objects that are returned and the class specified)
76
- /// </param>
77
- public SQLHelper ( IConnection connection , ObjectPool < StringBuilder > ? stringBuilderPool = null , Aspectus . Aspectus ? aopManager = null , Manager ? dataMapper = null )
42
+ /// <param name="stringBuilderPool">The string builder pool.</param>
43
+ /// <param name="dynamoFactory">The dynamo factory.</param>
44
+ /// <param name="configuration">The configuration.</param>
45
+ public SQLHelper ( ObjectPool < StringBuilder > stringBuilderPool , DynamoFactory dynamoFactory , IConfiguration configuration )
78
46
{
79
47
StringBuilderPool = stringBuilderPool ;
80
- AopManager = aopManager ;
81
- DataMapper = dataMapper ;
82
- SetConnection ( connection ) ;
48
+ DynamoFactory = dynamoFactory ;
49
+ Configuration = configuration ;
50
+ SetConnection ( new Connection ( configuration , SqlClientFactory . Instance , "Default" ) ) ;
83
51
}
84
52
85
53
/// <summary>
@@ -92,7 +60,7 @@ public SQLHelper(IConnection connection, ObjectPool<StringBuilder>? stringBuilde
92
60
/// Gets or sets the source.
93
61
/// </summary>
94
62
/// <value>The source.</value>
95
- public IConnection DatabaseConnection { get ; private set ; }
63
+ public IConnection ? DatabaseConnection { get ; private set ; }
96
64
97
65
/// <summary>
98
66
/// Gets the batch.
@@ -101,28 +69,28 @@ public SQLHelper(IConnection connection, ObjectPool<StringBuilder>? stringBuilde
101
69
protected IBatch Batch { get ; private set ; }
102
70
103
71
/// <summary>
104
- /// Gets the connections .
72
+ /// Gets the configuration .
105
73
/// </summary>
106
- /// <value>The connections .</value>
107
- private static ConcurrentDictionary < string , IConnection > Connections { get ; } = new ConcurrentDictionary < string , IConnection > ( ) ;
74
+ /// <value>The configuration .</value>
75
+ protected IConfiguration Configuration { get ; }
108
76
109
77
/// <summary>
110
- /// Gets the aop manager .
78
+ /// Gets the dynamo factory .
111
79
/// </summary>
112
- /// <value>The aop manager .</value>
113
- private Aspectus . Aspectus ? AopManager { get ; }
80
+ /// <value>The dynamo factory .</value>
81
+ protected DynamoFactory DynamoFactory { get ; }
114
82
115
83
/// <summary>
116
- /// Gets the data mapper .
84
+ /// Gets the string builder pool .
117
85
/// </summary>
118
- /// <value>The data mapper .</value>
119
- private Manager ? DataMapper { get ; }
86
+ /// <value>The string builder pool .</value>
87
+ protected ObjectPool < StringBuilder > StringBuilderPool { get ; }
120
88
121
89
/// <summary>
122
- /// Gets the string builder pool .
90
+ /// Gets the connections .
123
91
/// </summary>
124
- /// <value>The string builder pool .</value>
125
- private ObjectPool < StringBuilder > ? StringBuilderPool { get ; }
92
+ /// <value>The connections .</value>
93
+ private static ConcurrentDictionary < string , IConnection > Connections { get ; } = new ConcurrentDictionary < string , IConnection > ( ) ;
126
94
127
95
/// <summary>
128
96
/// Adds a query that gets carried across in internal batches.
@@ -213,11 +181,10 @@ public SQLHelper CreateBatch(IConnection connection)
213
181
/// <summary>
214
182
/// Creates the batch using the connection info specified.
215
183
/// </summary>
216
- /// <param name="configuration">The configuration.</param>
217
184
/// <param name="factory">The factory.</param>
218
185
/// <param name="database">The database.</param>
219
186
/// <returns>This.</returns>
220
- public SQLHelper CreateBatch ( IConfiguration configuration , DbProviderFactory ? factory = null , string database = "Default" ) => CreateBatch ( Connections . ContainsKey ( database ) ? Connections [ database ] : new Connection ( configuration , factory ?? SqlClientFactory . Instance , database ) ) ;
187
+ public SQLHelper CreateBatch ( DbProviderFactory ? factory = null , string database = "Default" ) => CreateBatch ( Connections . ContainsKey ( database ) ? Connections [ database ] : new Connection ( Configuration , factory ?? SqlClientFactory . Instance , database ) ) ;
221
188
222
189
/// <summary>
223
190
/// Executes the queries asynchronously.
@@ -274,7 +241,7 @@ private void SetConnection(IConnection connection)
274
241
DatabaseConnection = connection ?? throw new ArgumentNullException ( nameof ( connection ) ) ;
275
242
if ( ! Connections . ContainsKey ( connection . Name ) )
276
243
Connections . AddOrUpdate ( connection . Name , connection , ( _ , value ) => value ) ;
277
- Batch ??= new Batch ( DatabaseConnection , StringBuilderPool , AopManager , DataMapper ) ;
244
+ Batch ??= new Batch ( DatabaseConnection , StringBuilderPool , DynamoFactory ) ;
278
245
Batch . SetConnection ( DatabaseConnection ) ;
279
246
}
280
247
}
0 commit comments