File tree Expand file tree Collapse file tree 1 file changed +27
-5
lines changed
Expand file tree Collapse file tree 1 file changed +27
-5
lines changed Original file line number Diff line number Diff line change 11# DataAbstractions.Dapper
2-
2+ A light abstraction around Dapper and Dapper.Contrib that also maintains the behavior IDbConnection.
33## Basic Usage
44
5- Create a connection adapter
5+ Create a data accessor
66
77``` csharp
88
9- var dataAccessor = new DataAccessor (new SqlConnection (connectionString ));
9+ IDataAccessor dataAccessor = new DataAccessor (new SqlConnection (connectionString ));
1010
1111```
12- Execute Dapper queries and sql commands normally
12+ Execute Dapper queries and sql commands normally.
1313
1414``` csharp
1515
1616var person = await dataAccessor .QueryAsync <Person >(sql , new {Id });
1717
18- ```
18+ ```
19+
20+ Note: You need to dispose of the dataAccessor as your would with IDbConnection.
21+
22+ ## Dapper.Contrib methods
23+
24+ IDataAccessor includes Dapper.Contrib methods
25+
26+ ``` csharp
27+
28+ dataAccessor .Insert (new Person { Name = " John Doe" });
29+
30+ ```
31+
32+ ## IDbConnection methods
33+
34+ IDataAccessor implements IDbConnection, so you can access things like the ConnectionTimeout value.
35+
36+ ``` csharp
37+
38+ var timeout = dataAccessor .ConnectionTimeout ;
39+
40+ ```
You can’t perform that action at this time.
0 commit comments