Commit 22bf22c1 authored by Xavier Poinas's avatar Xavier Poinas

Added support for reading multiple result sets as dynamic

parent a561cb98
...@@ -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>
......
...@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment