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
5633d879
Commit
5633d879
authored
Sep 07, 2011
by
David Chell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reinstated support for Sql server using #define.
Signed-off-by:
David Chell
<
david@qualitech.co.nz
>
parent
64666d5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
2 deletions
+13
-2
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+13
-2
No files found.
Dapper.Contrib/SqlMapperExtensions.cs
View file @
5633d879
using
System
;
#
define
POSTGRESQL
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.Data
;
using
System.Data
;
using
System.Diagnostics
;
using
System.Diagnostics
;
...
@@ -174,9 +176,11 @@ private static string GetTableName(Type type)
...
@@ -174,9 +176,11 @@ private static string GetTableName(Type type)
if
(
i
<
allPropertiesExceptKey
.
Count
()
-
1
)
if
(
i
<
allPropertiesExceptKey
.
Count
()
-
1
)
sb
.
Append
(
", "
);
sb
.
Append
(
", "
);
}
}
long
id
=
0
;
#if POSTGRESQL
sb
.
Append
(
") RETURNING * "
);
sb
.
Append
(
") RETURNING * "
);
var
r
=
connection
.
Query
(
sb
.
ToString
(),
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
r
=
connection
.
Query
(
sb
.
ToString
(),
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
long
id
=
0
;
// Return the key py assinging the corresponding property in the object - by product is that it supports compound primary keys
foreach
(
var
p
in
keyProperties
)
foreach
(
var
p
in
keyProperties
)
{
{
var
value
=
((
IDictionary
<
string
,
object
>)
r
.
First
())[
p
.
Name
.
ToLower
()];
var
value
=
((
IDictionary
<
string
,
object
>)
r
.
First
())[
p
.
Name
.
ToLower
()];
...
@@ -184,6 +188,13 @@ private static string GetTableName(Type type)
...
@@ -184,6 +188,13 @@ private static string GetTableName(Type type)
if
(
id
==
0
)
if
(
id
==
0
)
id
=
Convert
.
ToInt64
(
value
);
id
=
Convert
.
ToInt64
(
value
);
}
}
#else
sb
.
Append
(
") "
);
connection
.
Execute
(
sb
.
ToString
(),
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
//NOTE: would prefer to use IDENT_CURRENT('tablename') or IDENT_SCOPE but these are not available on SQLCE
var
r
=
connection
.
Query
(
"select @@IDENTITY id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
id
=
(
int
)
r
.
First
().
id
;
#endif
return
id
;
return
id
;
}
}
...
...
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