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
4e187f01
Commit
4e187f01
authored
May 28, 2013
by
Marc Gravell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added example/test for
http://stackoverflow.com/q/16796519/23354
parent
bdf56330
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
Tests.cs
Tests/Tests.cs
+31
-0
No files found.
Tests/Tests.cs
View file @
4e187f01
...
@@ -12,6 +12,7 @@
...
@@ -12,6 +12,7 @@
using
System.Dynamic
;
using
System.Dynamic
;
using
System.ComponentModel
;
using
System.ComponentModel
;
using
Microsoft.CSharp.RuntimeBinder
;
using
Microsoft.CSharp.RuntimeBinder
;
using
System.Data.Common
;
#if POSTGRESQL
#if POSTGRESQL
using
Npgsql
;
using
Npgsql
;
#endif
#endif
...
@@ -1613,6 +1614,36 @@ public void TestMultiMapThreeTypesWithGridReader()
...
@@ -1613,6 +1614,36 @@ public void TestMultiMapThreeTypesWithGridReader()
connection
.
Execute
(
"drop table #Users drop table #Posts drop table #Comments"
);
connection
.
Execute
(
"drop table #Users drop table #Posts drop table #Comments"
);
}
}
public
class
DbParams
:
Dapper
.
SqlMapper
.
IDynamicParameters
,
IEnumerable
<
IDbDataParameter
>
{
private
readonly
List
<
IDbDataParameter
>
parameters
=
new
List
<
IDbDataParameter
>();
public
IEnumerator
<
IDbDataParameter
>
GetEnumerator
()
{
return
parameters
.
GetEnumerator
();
}
IEnumerator
IEnumerable
.
GetEnumerator
()
{
return
GetEnumerator
();
}
public
void
Add
(
IDbDataParameter
value
)
{
parameters
.
Add
(
value
);
}
void
Dapper
.
SqlMapper
.
IDynamicParameters
.
AddParameters
(
IDbCommand
command
,
Dapper
.
SqlMapper
.
Identity
identity
)
{
foreach
(
IDbDataParameter
parameter
in
parameters
)
command
.
Parameters
.
Add
(
parameter
);
}
}
public
void
TestCustomParameters
()
{
var
args
=
new
DbParams
{
new
SqlParameter
(
"foo"
,
123
),
new
SqlParameter
(
"bar"
,
"abc"
)
};
var
result
=
connection
.
Query
(
"select Foo=@foo, Bar=@bar"
,
args
).
Single
();
int
foo
=
result
.
Foo
;
string
bar
=
result
.
Bar
;
foo
.
IsEqualTo
(
123
);
bar
.
IsEqualTo
(
"abc"
);
}
public
void
TestReadDynamicWithGridReader
()
public
void
TestReadDynamicWithGridReader
()
{
{
var
createSql
=
@"
var
createSql
=
@"
...
...
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