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
22bf22c1
Commit
22bf22c1
authored
Feb 14, 2012
by
Xavier Poinas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added support for reading multiple result sets as dynamic
parent
a561cb98
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
SqlMapper.cs
Dapper/SqlMapper.cs
+13
-0
Tests.cs
Tests/Tests.cs
+32
-0
No files found.
Dapper/SqlMapper.cs
View file @
22bf22c1
...
@@ -1736,6 +1736,19 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity)
...
@@ -1736,6 +1736,19 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity)
this
.
reader
=
reader
;
this
.
reader
=
reader
;
this
.
identity
=
identity
;
this
.
identity
=
identity
;
}
}
#if !CSHARP30
/// <summary>
/// Read the next grid of results, returned as a dynamic object
/// </summary>
public
IEnumerable
<
dynamic
>
Read
()
{
return
Read
<
FastExpando
>();
}
#endif
/// <summary>
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
/// </summary>
/// </summary>
...
...
Tests/Tests.cs
View file @
22bf22c1
...
@@ -1117,6 +1117,38 @@ public void TestMultiMapThreeTypesWithGridReader()
...
@@ -1117,6 +1117,38 @@ 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
void
TestReadDynamicWithGridReader
()
{
var
createSql
=
@"
create table #Users (Id int, Name varchar(20))
create table #Posts (Id int, OwnerId int, Content varchar(20))
insert #Users values(99, 'Sam')
insert #Users values(2, 'I am')
insert #Posts values(1, 99, 'Sams Post1')
insert #Posts values(2, 99, 'Sams Post2')
insert #Posts values(3, null, 'no ones post')"
;
connection
.
Execute
(
createSql
);
var
sql
=
@"SELECT * FROM #Users ORDER BY Id
SELECT * FROM #Posts ORDER BY Id DESC"
;
var
grid
=
connection
.
QueryMultiple
(
sql
);
var
users
=
grid
.
Read
().
ToList
();
var
posts
=
grid
.
Read
().
ToList
();
users
.
Count
.
IsEqualTo
(
2
);
posts
.
Count
.
IsEqualTo
(
3
);
((
int
)
users
.
First
().
Id
).
IsEqualTo
(
2
);
((
int
)
posts
.
First
().
Id
).
IsEqualTo
(
3
);
connection
.
Execute
(
"drop table #Users drop table #Posts"
);
}
public
void
TestDynamicParamNullSupport
()
public
void
TestDynamicParamNullSupport
()
{
{
var
p
=
new
DynamicParameters
();
var
p
=
new
DynamicParameters
();
...
...
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