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
9b98d3df
Commit
9b98d3df
authored
May 07, 2017
by
Nick Craver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Documentation: GridReader
parent
d52067c8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
148 additions
and
94 deletions
+148
-94
SqlMapper.GridReader.Async.cs
Dapper/SqlMapper.GridReader.Async.cs
+40
-52
SqlMapper.GridReader.cs
Dapper/SqlMapper.GridReader.cs
+108
-42
No files found.
Dapper/SqlMapper.GridReader.Async.cs
View file @
9b98d3df
...
...
@@ -24,50 +24,39 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity, D
/// Read the next grid of results, returned as a dynamic object
/// </summary>
/// <remarks>Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
IEnumerable
<
dynamic
>>
ReadAsync
(
bool
buffered
=
true
)
{
return
ReadAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
}
/// <param name="buffered">Whether to buffer the results.</param>
public
Task
<
IEnumerable
<
dynamic
>>
ReadAsync
(
bool
buffered
=
true
)
=>
ReadAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadFirstAsync
()
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
}
public
Task
<
dynamic
>
ReadFirstAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadFirstOrDefaultAsync
()
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
}
public
Task
<
dynamic
>
ReadFirstOrDefaultAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadSingleAsync
()
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
}
public
Task
<
dynamic
>
ReadSingleAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadSingleOrDefaultAsync
()
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
}
public
Task
<
dynamic
>
ReadSingleOrDefaultAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
/// <summary>
/// Read the next grid of results
/// </summary>
/// <param name="type">The type to read.</param>
/// <param name="buffered">Whether to buffer the results.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
Task
<
IEnumerable
<
object
>>
ReadAsync
(
Type
type
,
bool
buffered
=
true
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -77,6 +66,8 @@ public Task<IEnumerable<object>> ReadAsync(Type type, bool buffered = true)
/// <summary>
/// Read an individual row of the next grid of results
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
Task
<
object
>
ReadFirstAsync
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -84,8 +75,10 @@ public Task<object> ReadFirstAsync(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
Task
<
object
>
ReadFirstOrDefaultAsync
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -93,8 +86,10 @@ public Task<object> ReadFirstOrDefaultAsync(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
Task
<
object
>
ReadSingleAsync
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -102,8 +97,10 @@ public Task<object> ReadSingleAsync(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
Task
<
object
>
ReadSingleOrDefaultAsync
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -111,44 +108,35 @@ public Task<object> ReadSingleOrDefaultAsync(Type type)
}
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
public
Task
<
IEnumerable
<
T
>>
ReadAsync
<
T
>(
bool
buffered
=
true
)
{
return
ReadAsyncImpl
<
T
>(
typeof
(
T
),
buffered
);
}
/// <typeparam name="T">The type to read.</typeparam>
/// <param name="buffered">Whether the results should be buffered in memory.</param>
public
Task
<
IEnumerable
<
T
>>
ReadAsync
<
T
>(
bool
buffered
=
true
)
=>
ReadAsyncImpl
<
T
>(
typeof
(
T
),
buffered
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
Task
<
T
>
ReadFirstAsync
<
T
>()
{
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
First
);
}
/// <typeparam name="T">The type to read.</typeparam>
public
Task
<
T
>
ReadFirstAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
First
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
Task
<
T
>
ReadFirstOrDefaultAsync
<
T
>()
{
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
}
/// <typeparam name="T">The type to read.</typeparam>
public
Task
<
T
>
ReadFirstOrDefaultAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
Task
<
T
>
ReadSingleAsync
<
T
>()
{
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
Single
);
}
/// <typeparam name="T">The type to read.</typeparam>
public
Task
<
T
>
ReadSingleAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
Single
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
Task
<
T
>
ReadSingleOrDefaultAsync
<
T
>()
{
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
}
/// <typeparam name="T">The type to read.</typeparam>
public
Task
<
T
>
ReadSingleOrDefaultAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
private
async
Task
NextResultAsync
()
{
...
...
@@ -186,11 +174,11 @@ private Task<IEnumerable<T>> ReadAsyncImpl<T>(Type type, bool buffered)
IsConsumed
=
true
;
if
(
buffered
&&
reader
is
DbDataReader
)
{
return
ReadBufferedAsync
<
T
>(
gridIndex
,
deserializer
.
Func
,
typedIdentity
);
return
ReadBufferedAsync
<
T
>(
gridIndex
,
deserializer
.
Func
);
}
else
{
var
result
=
ReadDeferred
<
T
>(
gridIndex
,
deserializer
.
Func
,
type
dIdentity
,
type
);
var
result
=
ReadDeferred
<
T
>(
gridIndex
,
deserializer
.
Func
,
type
);
if
(
buffered
)
result
=
result
.
ToList
();
// for the "not a DbDataReader" scenario
return
Task
.
FromResult
(
result
);
}
...
...
@@ -201,7 +189,7 @@ private Task<T> ReadRowAsyncImpl<T>(Type type, Row row)
if
(
reader
is
DbDataReader
dbReader
)
return
ReadRowAsyncImplViaDbReader
<
T
>(
dbReader
,
type
,
row
);
// no async API available; use non-async and fake it
return
Task
.
FromResult
<
T
>
(
ReadRow
<
T
>(
type
,
row
));
return
Task
.
FromResult
(
ReadRow
<
T
>(
type
,
row
));
}
private
async
Task
<
T
>
ReadRowAsyncImplViaDbReader
<
T
>(
DbDataReader
reader
,
Type
type
,
Row
row
)
...
...
@@ -235,7 +223,7 @@ private async Task<T> ReadRowAsyncImplViaDbReader<T>(DbDataReader reader, Type t
return
result
;
}
private
async
Task
<
IEnumerable
<
T
>>
ReadBufferedAsync
<
T
>(
int
index
,
Func
<
IDataReader
,
object
>
deserializer
,
Identity
typedIdentity
)
private
async
Task
<
IEnumerable
<
T
>>
ReadBufferedAsync
<
T
>(
int
index
,
Func
<
IDataReader
,
object
>
deserializer
)
{
try
{
...
...
Dapper/SqlMapper.GridReader.cs
View file @
9b98d3df
...
...
@@ -26,73 +26,73 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity, I
}
/// <summary>
/// Read the next grid of results, returned as a dynamic object
/// Read the next grid of results, returned as a dynamic object
.
/// </summary>
/// <param name="buffered">Whether the results should be buffered in memory.</param>
/// <remarks>Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
IEnumerable
<
dynamic
>
Read
(
bool
buffered
=
true
)
=>
ReadImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
public
IEnumerable
<
dynamic
>
Read
(
bool
buffered
=
true
)
=>
ReadImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// Read an individual row of the next grid of results, returned as a dynamic object
.
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadFirst
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
public
dynamic
ReadFirst
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// Read an individual row of the next grid of results, returned as a dynamic object
.
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadFirstOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
public
dynamic
ReadFirstOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// Read an individual row of the next grid of results, returned as a dynamic object
.
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadSingle
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
public
dynamic
ReadSingle
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
/// <summary>
/// Read an individual row of the next grid of results, returned as a dynamic object
/// Read an individual row of the next grid of results, returned as a dynamic object
.
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadSingleOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
public
dynamic
ReadSingleOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
public
IEnumerable
<
T
>
Read
<
T
>(
bool
buffered
=
true
)
=>
ReadImpl
<
T
>(
typeof
(
T
),
buffered
);
/// <typeparam name="T">The type to read.</typeparam>
/// <param name="buffered">Whether the results should be buffered in memory.</param>
public
IEnumerable
<
T
>
Read
<
T
>(
bool
buffered
=
true
)
=>
ReadImpl
<
T
>(
typeof
(
T
),
buffered
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
T
ReadFirst
<
T
>()
=
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
First
);
/// <typeparam name="T">The type to read.</typeparam
>
public
T
ReadFirst
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
First
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
T
ReadFirstOrDefault
<
T
>()
=
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
/// <typeparam name="T">The type to read.</typeparam
>
public
T
ReadFirstOrDefault
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
T
ReadSingle
<
T
>()
=
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
Single
);
/// <typeparam name="T">The type to read.</typeparam
>
public
T
ReadSingle
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
Single
);
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
public
T
ReadSingleOrDefault
<
T
>()
=
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
/// <typeparam name="T">The type to read.</typeparam
>
public
T
ReadSingleOrDefault
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <param name="buffered">Whether to buffer the results.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
IEnumerable
<
object
>
Read
(
Type
type
,
bool
buffered
=
true
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -100,8 +100,10 @@ public IEnumerable<object> Read(Type type, bool buffered = true)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
object
ReadFirst
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -109,8 +111,10 @@ public object ReadFirst(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
object
ReadFirstOrDefault
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -118,8 +122,10 @@ public object ReadFirstOrDefault(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
object
ReadSingle
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -127,8 +133,10 @@ public object ReadSingle(Type type)
}
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// <param name="type">The type to read.</param>
/// <exception cref="ArgumentNullException"><paramref name="type"/> is <c>null</c>.</exception>
public
object
ReadSingleOrDefault
(
Type
type
)
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
...
@@ -150,7 +158,7 @@ private IEnumerable<T> ReadImpl<T>(Type type, bool buffered)
cache
.
Deserializer
=
deserializer
;
}
IsConsumed
=
true
;
var
result
=
ReadDeferred
<
T
>(
gridIndex
,
deserializer
.
Func
,
type
dIdentity
,
type
);
var
result
=
ReadDeferred
<
T
>(
gridIndex
,
deserializer
.
Func
,
type
);
return
buffered
?
result
.
ToList
()
:
result
;
}
...
...
@@ -174,10 +182,12 @@ private T ReadRow<T>(Type type, Row row)
cache
.
Deserializer
=
deserializer
;
}
object
val
=
deserializer
.
Func
(
reader
);
if
(
val
==
null
||
val
is
T
)
if
(
val
==
null
||
val
is
T
)
{
result
=
(
T
)
val
;
}
else
{
}
else
{
var
convertToType
=
Nullable
.
GetUnderlyingType
(
type
)
??
type
;
result
=
(
T
)
Convert
.
ChangeType
(
val
,
convertToType
,
CultureInfo
.
InvariantCulture
);
}
...
...
@@ -236,8 +246,14 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
}
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
.
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -245,8 +261,15 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
}
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
.
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TThird">The third type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TThird
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TThird
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
TThird
,
DontMap
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -256,6 +279,14 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TThird">The third type in the record set.</typeparam>
/// <typeparam name="TFourth">The fourth type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
DontMap
,
DontMap
,
DontMap
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -265,6 +296,15 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TThird">The third type in the record set.</typeparam>
/// <typeparam name="TFourth">The fourth type in the record set.</typeparam>
/// <typeparam name="TFifth">The fifth type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
DontMap
,
DontMap
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -274,6 +314,16 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TThird">The third type in the record set.</typeparam>
/// <typeparam name="TFourth">The fourth type in the record set.</typeparam>
/// <typeparam name="TFifth">The fifth type in the record set.</typeparam>
/// <typeparam name="TSixth">The sixth type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
DontMap
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -283,6 +333,17 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
/// <typeparam name="TFirst">The first type in the record set.</typeparam>
/// <typeparam name="TSecond">The second type in the record set.</typeparam>
/// <typeparam name="TThird">The third type in the record set.</typeparam>
/// <typeparam name="TFourth">The fourth type in the record set.</typeparam>
/// <typeparam name="TFifth">The fifth type in the record set.</typeparam>
/// <typeparam name="TSixth">The sixth type in the record set.</typeparam>
/// <typeparam name="TSeventh">The seventh type in the record set.</typeparam>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="func">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>(
Func
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>
func
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TFirst
,
TSecond
,
TThird
,
TFourth
,
TFifth
,
TSixth
,
TSeventh
,
TReturn
>(
func
,
splitOn
);
...
...
@@ -292,13 +353,18 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// Read multiple objects from a single record set on the grid
/// </summary>
/// <typeparam name="TReturn">The type to return from the record set.</typeparam>
/// <param name="types">The types to read from the result set.</param>
/// <param name="map">The mapping function from the read types to the return type.</param>
/// <param name="splitOn">The field(s) we should split and read the second object from (defaults to "id")</param>
/// <param name="buffered">Whether to buffer results in memory.</param>
public
IEnumerable
<
TReturn
>
Read
<
TReturn
>(
Type
[]
types
,
Func
<
object
[],
TReturn
>
map
,
string
splitOn
=
"id"
,
bool
buffered
=
true
)
{
var
result
=
MultiReadInternal
<
TReturn
>
(
types
,
map
,
splitOn
);
var
result
=
MultiReadInternal
(
types
,
map
,
splitOn
);
return
buffered
?
result
.
ToList
()
:
result
;
}
private
IEnumerable
<
T
>
ReadDeferred
<
T
>(
int
index
,
Func
<
IDataReader
,
object
>
deserializer
,
Identity
typedIdentity
,
Type
effectiveType
)
private
IEnumerable
<
T
>
ReadDeferred
<
T
>(
int
index
,
Func
<
IDataReader
,
object
>
deserializer
,
Type
effectiveType
)
{
try
{
...
...
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