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
19faf7cc
Commit
19faf7cc
authored
Sep 09, 2012
by
Sam
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #48 from romanych/master
Support of types for Id column in Dapper.Rainbow
parents
c6735ebc
d0423de6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
Database.cs
Dapper.Rainbow/Database.cs
+11
-4
No files found.
Dapper.Rainbow/Database.cs
View file @
19faf7cc
...
...
@@ -24,7 +24,7 @@ namespace Dapper
/// <typeparam name="TDatabase"></typeparam>
public
abstract
class
Database
<
TDatabase
>
:
IDisposable
where
TDatabase
:
Database
<
TDatabase
>,
new
()
{
public
class
Table
<
T
>
public
class
Table
<
T
,
TId
>
{
internal
Database
<
TDatabase
>
database
;
internal
string
tableName
;
...
...
@@ -68,7 +68,7 @@ public string TableName
/// <param name="id"></param>
/// <param name="data"></param>
/// <returns></returns>
public
int
Update
(
int
id
,
dynamic
data
)
public
int
Update
(
TId
id
,
dynamic
data
)
{
List
<
string
>
paramNames
=
GetParamNames
((
object
)
data
);
...
...
@@ -88,7 +88,7 @@ public int Update(int id, dynamic data)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
bool
Delete
(
int
id
)
public
bool
Delete
(
TId
id
)
{
return
database
.
Execute
(
"delete "
+
TableName
+
" where Id = @id"
,
new
{
id
})
>
0
;
}
...
...
@@ -98,7 +98,7 @@ public bool Delete(int id)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public
T
Get
(
int
id
)
public
T
Get
(
TId
id
)
{
return
database
.
Query
<
T
>(
"select * from "
+
TableName
+
" where Id = @id"
,
new
{
id
}).
FirstOrDefault
();
}
...
...
@@ -136,6 +136,13 @@ internal static List<string> GetParamNames(object o)
}
}
public
class
Table
<
T
>
:
Table
<
T
,
int
>
{
public
Table
(
Database
<
TDatabase
>
database
,
string
likelyTableName
)
:
base
(
database
,
likelyTableName
)
{
}
}
DbConnection
connection
;
int
commandTimeout
;
DbTransaction
transaction
;
...
...
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