1- using Dapper . Contrib . Extensions ;
2- using System ;
1+ using System ;
32using System . Collections . Generic ;
43using System . Data ;
54using System . Data . SqlClient ;
65using System . Threading . Tasks ;
76
8- namespace Dapper . Connection . Abstractions
7+ namespace Dapper . Testability . Adapters
98{
10- public class DapperConnection : IDapperConnection
9+ //This partial class is reserved for the Dapper implementation
10+ public partial class ConnectionAdapter
1111 {
12- private readonly IDbConnection _connection ;
13-
14- public DapperConnection ( IDbConnection connection )
15- {
16- _connection = connection ?? throw new ArgumentNullException ( nameof ( connection ) ) ;
17- }
18-
19- public string ConnectionString
20- {
21- get => _connection . ConnectionString ;
22- set => _connection . ConnectionString = value ;
23- }
24-
25- public int ConnectionTimeout => _connection . ConnectionTimeout ;
26-
27- public string Database => _connection . Database ;
28-
29- public ConnectionState State => _connection . State ;
30-
31- public IDbTransaction BeginTransaction ( )
32- {
33- return _connection . BeginTransaction ( ) ;
34- }
35-
36- public IDbTransaction BeginTransaction ( IsolationLevel il )
37- {
38- return _connection . BeginTransaction ( il ) ;
39- }
40-
41- public void Close ( )
42- {
43- _connection . Close ( ) ;
44- }
45-
46- public void ChangeDatabase ( string databaseName )
47- {
48- _connection . ChangeDatabase ( databaseName ) ;
49- }
50-
51- public IDbCommand CreateCommand ( )
52- {
53- return _connection . CreateCommand ( ) ;
54- }
55-
56- public void Open ( )
57- {
58- _connection . Open ( ) ;
59- }
60-
61-
6212 public IEnumerable < T > Query < T > ( string sql , object param = null , SqlTransaction transaction = null , bool buffered = true ) =>
6313 _connection . Query < T > ( sql , param , transaction , buffered ) ;
6414
@@ -344,51 +294,5 @@ public IEnumerable<TReturn> Query<TFirst, TSecond, TThird, TFourth, TFifth, TSix
344294 public IEnumerable < TReturn > Query < TReturn > ( string sql , Type [ ] types , Func < object [ ] , TReturn > map , object param = null , IDbTransaction transaction = null , bool buffered = true , string splitOn = "Id" , int ? commandTimeout = null , CommandType ? commandType = null ) =>
345295 _connection . Query ( sql , types , map , param , transaction , buffered , splitOn , commandTimeout , commandType ) ;
346296
347- public Task < T > GetAsync < T > ( dynamic id , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
348- SqlMapperExtensions . GetAsync < T > ( _connection , id , transaction , commandTimeout ) ;
349-
350- public Task < IEnumerable < T > > GetAllAsync < T > ( IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
351- _connection . GetAllAsync < T > ( transaction , commandTimeout ) ;
352-
353- public Task < int > InsertAsync < T > ( T entityToInsert , IDbTransaction transaction = null , int ? commandTimeout = null , ISqlAdapter sqlAdapter = null ) where T : class =>
354- _connection . InsertAsync ( entityToInsert , transaction , commandTimeout , sqlAdapter ) ;
355-
356- public Task < bool > UpdateAsync < T > ( T entityToUpdate , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
357- _connection . UpdateAsync ( entityToUpdate , transaction , commandTimeout ) ;
358-
359- public Task < bool > DeleteAsync < T > ( T entityToDelete , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
360- _connection . DeleteAsync ( entityToDelete , transaction , commandTimeout ) ;
361-
362- public Task < bool > DeleteAllAsync < T > ( IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
363- _connection . DeleteAllAsync < T > ( transaction , commandTimeout ) ;
364-
365- public T Get < T > ( dynamic id , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
366- SqlMapperExtensions . Get < T > ( _connection , id , transaction , commandTimeout ) ;
367-
368- public IEnumerable < T > GetAll < T > ( IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
369- _connection . GetAll < T > ( transaction , commandTimeout ) ;
370-
371- public long Insert < T > ( T entityToInsert , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
372- _connection . Insert ( entityToInsert , transaction , commandTimeout ) ;
373-
374- public bool Update < T > ( T entityToUpdate , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
375- _connection . Update ( entityToUpdate , transaction , commandTimeout ) ;
376-
377- public bool Delete < T > ( T entityToDelete , IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
378- _connection . Delete ( entityToDelete , transaction , commandTimeout ) ;
379-
380- public bool DeleteAll < T > ( IDbTransaction transaction = null , int ? commandTimeout = null ) where T : class =>
381- _connection . DeleteAll < T > ( transaction , commandTimeout ) ;
382-
383-
384-
385- public void Dispose ( )
386- {
387- _connection . Dispose ( ) ;
388- }
389-
390-
391297 }
392-
393-
394298}
0 commit comments