Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
Dapper
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tsai
Dapper
Commits
8848e37e
Commit
8848e37e
authored
May 01, 2015
by
Johan Danforth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Started a readme for Dapper.Contrib
parent
a67ed727
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
Readme.md
Dapper.Contrib/Readme.md
+66
-0
No files found.
Dapper.Contrib/Readme.md
0 → 100644
View file @
8848e37e
Dapper.Contrib - more extensions for dapper
===========================================
Features
--------
Dapper.Contrib contains a number of helper methods for inserting, getting, updating and deleting files.
The object you are working with must have a property named Id or a property marked with a
[
Key
]
attribute. As with dapper,
all extension methods assume the connection is already open, they will fail if the connection is closed.
Inserts
-------
```
csharp
public
static
long
Insert
<
T
>(
this
IDbConnection
connection
,
T
entityToInsert
,
IDbTransaction
transaction
=
null
,
int
?
commandTimeout
=
null
)
```
```
csharp
public
class
Car
{
public
int
Id
{
get
;
set
;
}
public
string
Name
{
get
;
set
;
}
}
connection
.
Insert
(
new
Car
{
Name
=
"Volvo"
});
```
Gets
-------
```
csharp
public
static
T
Get
<
T
>(
this
IDbConnection
connection
,
dynamic
id
,
IDbTransaction
transaction
=
null
,
int
?
commandTimeout
=
null
)
```
```
csharp
var
car
=
connection
.
Get
<
Car
>(
1
);
```
Updates
-------
```
csharp
public
static
bool
Update
<
T
>(
this
IDbConnection
connection
,
T
entityToUpdate
,
IDbTransaction
transaction
=
null
,
int
?
commandTimeout
=
null
)
```
```
csharp
connection
.
Update
(
new
Car
()
{
Id
=
1
,
Name
=
"Saab"
});
```
Deletes
-------
```
csharp
public
static
bool
Delete
<
T
>(
this
IDbConnection
connection
,
T
entityToDelete
,
IDbTransaction
transaction
=
null
,
int
?
commandTimeout
=
null
)
public
static
bool
DeleteAll
<
T
>(
this
IDbConnection
connection
,
IDbTransaction
transaction
=
null
,
int
?
commandTimeout
=
null
)
```
```
csharp
connection
.
Delete
(
new
Car
()
{
Id
=
1
});
connection
.
DeleteAll
<
Car
>();
```
Attributes
----------
Dapper.Contrib makes use of some optional attributes:
*
Table("Tablename") - use another table name instead of the name of the class
*
Key - this property is the identity/key (unless it is named "Id")
*
Write(true/false) - this property is (not) writeable
*
Computed - this property is computed and should not be part of updates
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment