Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the GridReader.Read method with Type [] types and … #308

Merged
merged 1 commit into from Oct 15, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions Dapper NET40/SqlMapper.cs
Expand Up @@ -4312,6 +4312,22 @@ private IEnumerable<T> ReadImpl<T>(Type type, bool buffered)
}
}

private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<object[], TReturn> map, string splitOn)
{
var identity = this.identity.ForGrid(typeof(TReturn), types, gridIndex);
try
{
foreach (var r in SqlMapper.MultiMapImpl<TReturn>(null, default(CommandDefinition), types, map, splitOn, reader, identity, false))
{
yield return r;
}
}
finally
{
NextResult();
}
}

#if CSHARP30
/// <summary>
/// Read multiple objects from a single record set on the grid
Expand Down Expand Up @@ -4406,6 +4422,16 @@ private IEnumerable<T> ReadImpl<T>(Type type, bool buffered)
var result = MultiReadInternal<TFirst, TSecond, TThird, TFourth, TFifth, TSixth, TSeventh, TReturn>(func, splitOn);
return buffered ? result.ToList() : result;
}

/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
public IEnumerable<TReturn> Read<TReturn>(Type[] types, Func<object [], TReturn> map, string splitOn = "id", bool buffered = true)
{
var result = MultiReadInternal<TReturn>(types, map, splitOn);
return buffered ? result.ToList() : result;
}

#endif

private IEnumerable<T> ReadDeferred<T>(int index, Func<IDataReader, object> deserializer, Identity typedIdentity)
Expand Down