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
70a9c31b
Commit
70a9c31b
authored
May 07, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'HEAD' of
https://github.com/SamSaffron/dapper-dot-net.git
parents
01157915
aec9a9d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+7
-2
SqlMapperExtensions.cs
Dapper.Contrib/SqlMapperExtensions.cs
+22
-2
No files found.
Dapper NET40/SqlMapper.cs
View file @
70a9c31b
...
@@ -3231,8 +3231,9 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
...
@@ -3231,8 +3231,9 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
var
dbType
=
param
.
DbType
;
var
dbType
=
param
.
DbType
;
var
val
=
param
.
Value
;
var
val
=
param
.
Value
;
string
name
=
Clean
(
param
.
Name
);
string
name
=
Clean
(
param
.
Name
);
var
isCustomQueryParameter
=
typeof
(
SqlMapper
.
ICustomQueryParameter
).
IsAssignableFrom
(
val
.
GetType
());
if
(
dbType
==
null
&&
val
!=
null
)
dbType
=
SqlMapper
.
LookupDbType
(
val
.
GetType
(),
name
);
if
(
dbType
==
null
&&
val
!=
null
&&
!
isCustomQueryParameter
)
dbType
=
SqlMapper
.
LookupDbType
(
val
.
GetType
(),
name
);
if
(
dbType
==
DynamicParameters
.
EnumerableMultiParameter
)
if
(
dbType
==
DynamicParameters
.
EnumerableMultiParameter
)
{
{
...
@@ -3240,6 +3241,10 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
...
@@ -3240,6 +3241,10 @@ protected void AddParameters(IDbCommand command, SqlMapper.Identity identity)
SqlMapper
.
PackListParameters
(
command
,
name
,
val
);
SqlMapper
.
PackListParameters
(
command
,
name
,
val
);
#pragma warning restore 612, 618
#pragma warning restore 612, 618
}
}
else
if
(
isCustomQueryParameter
)
{
((
SqlMapper
.
ICustomQueryParameter
)
val
).
AddParameter
(
command
,
name
);
}
else
else
{
{
...
@@ -3729,4 +3734,4 @@ public partial class FeatureSupport
...
@@ -3729,4 +3734,4 @@ public partial class FeatureSupport
#endif
#endif
}
}
\ No newline at end of file
Dapper.Contrib/SqlMapperExtensions.cs
View file @
70a9c31b
...
@@ -29,7 +29,8 @@ public interface IProxy
...
@@ -29,7 +29,8 @@ public interface IProxy
private
static
readonly
Dictionary
<
string
,
ISqlAdapter
>
AdapterDictionary
=
new
Dictionary
<
string
,
ISqlAdapter
>()
{
private
static
readonly
Dictionary
<
string
,
ISqlAdapter
>
AdapterDictionary
=
new
Dictionary
<
string
,
ISqlAdapter
>()
{
{
"sqlconnection"
,
new
SqlServerAdapter
()},
{
"sqlconnection"
,
new
SqlServerAdapter
()},
{
"npgsqlconnection"
,
new
PostgresAdapter
()}
{
"npgsqlconnection"
,
new
PostgresAdapter
()},
{
"sqliteconnection"
,
new
SQLiteAdapter
()}
};
};
private
static
IEnumerable
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
private
static
IEnumerable
<
PropertyInfo
>
ComputedPropertiesCache
(
Type
type
)
{
{
...
@@ -551,4 +552,23 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
...
@@ -551,4 +552,23 @@ public int Insert(IDbConnection connection, IDbTransaction transaction, int? com
}
}
return
id
;
return
id
;
}
}
}
}
\ No newline at end of file
public
class
SQLiteAdapter
:
ISqlAdapter
{
public
int
Insert
(
IDbConnection
connection
,
IDbTransaction
transaction
,
int
?
commandTimeout
,
String
tableName
,
string
columnList
,
string
parameterList
,
IEnumerable
<
PropertyInfo
>
keyProperties
,
object
entityToInsert
)
{
string
cmd
=
String
.
Format
(
"insert into {0} ({1}) values ({2})"
,
tableName
,
columnList
,
parameterList
);
connection
.
Execute
(
cmd
,
entityToInsert
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
var
r
=
connection
.
Query
(
"select last_insert_rowid() id"
,
transaction
:
transaction
,
commandTimeout
:
commandTimeout
);
int
id
=
(
int
)
r
.
First
().
id
;
if
(
keyProperties
.
Any
())
keyProperties
.
First
().
SetValue
(
entityToInsert
,
id
,
null
);
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