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
5abf74fb
Commit
5abf74fb
authored
Sep 22, 2014
by
Marc Gravell
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #179 from matwilko/idictionary-fix
Allow passing an IDictionary<string, object> as parameter object
parents
dc17868d
d2cce62d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
4 deletions
+15
-4
SqlMapper.cs
Dapper NET40/SqlMapper.cs
+6
-4
Tests.cs
Tests/Tests.cs
+9
-0
No files found.
Dapper NET40/SqlMapper.cs
View file @
5abf74fb
...
...
@@ -2048,9 +2048,12 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
{
info
.
ParamReader
=
(
cmd
,
obj
)
=>
{
((
IDynamicParameters
)
obj
).
AddParameters
(
cmd
,
identity
);
};
}
#if !CSHARP30
// special-case dictionary && `dynamic`
else
if
(
exampleParameters
is
IEnumerable
<
KeyValuePair
<
string
,
object
>>
&&
exampleParameters
is
System
.
Dynamic
.
IDynamicMetaObjectProvider
)
#if CSHARP30
else
if
(
exampleParameters
is
IEnumerable
<
KeyValuePair
<
string
,
object
>>)
#else
// special-case dictionary and `dynamic`
else
if
(
exampleParameters
is
IEnumerable
<
KeyValuePair
<
string
,
object
>>
||
exampleParameters
is
System
.
Dynamic
.
IDynamicMetaObjectProvider
)
#endif
{
info
.
ParamReader
=
(
cmd
,
obj
)
=>
{
...
...
@@ -2058,7 +2061,6 @@ private static CacheInfo GetCacheInfo(Identity identity, object exampleParameter
mapped
.
AddParameters
(
cmd
,
identity
);
};
}
#endif
else
{
var
literals
=
GetLiteralTokens
(
identity
.
sql
);
...
...
Tests/Tests.cs
View file @
5abf74fb
...
...
@@ -3842,6 +3842,15 @@ public void SO25297173_DynamicIn()
result
.
Contains
(
6
).
IsTrue
();
}
public
void
AllowIDictionaryParameters
()
{
var
parameters
=
new
Dictionary
<
string
,
object
>
{
{
"param1"
,
0
}
};
connection
.
Query
(
"SELECT @param1"
,
parameters
);
}
#if POSTGRESQL
class
Cat
...
...
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