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
...
@@ -24,50 +24,39 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity, D
/// Read the next grid of results, returned as a dynamic object
/// Read the next grid of results, returned as a dynamic object
/// </summary>
/// </summary>
/// <remarks>Note: each row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <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
)
/// <param name="buffered">Whether to buffer the results.</param>
{
public
Task
<
IEnumerable
<
dynamic
>>
ReadAsync
(
bool
buffered
=
true
)
=>
ReadAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
return
ReadAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
}
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadFirstAsync
()
public
Task
<
dynamic
>
ReadFirstAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
}
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadFirstOrDefaultAsync
()
public
Task
<
dynamic
>
ReadFirstOrDefaultAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
}
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadSingleAsync
()
public
Task
<
dynamic
>
ReadSingleAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
}
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
Task
<
dynamic
>
ReadSingleOrDefaultAsync
()
public
Task
<
dynamic
>
ReadSingleOrDefaultAsync
()
=>
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
{
return
ReadRowAsyncImpl
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
}
/// <summary>
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
/// </summary>
/// </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
)
public
Task
<
IEnumerable
<
object
>>
ReadAsync
(
Type
type
,
bool
buffered
=
true
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -77,6 +66,8 @@ public Task<IEnumerable<object>> ReadAsync(Type type, bool buffered = true)
...
@@ -77,6 +66,8 @@ public Task<IEnumerable<object>> ReadAsync(Type type, bool buffered = true)
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
/// </summary>
/// </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
)
public
Task
<
object
>
ReadFirstAsync
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -84,8 +75,10 @@ public Task<object> ReadFirstAsync(Type type)
...
@@ -84,8 +75,10 @@ public Task<object> ReadFirstAsync(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
Task
<
object
>
ReadFirstOrDefaultAsync
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -93,8 +86,10 @@ public Task<object> ReadFirstOrDefaultAsync(Type type)
...
@@ -93,8 +86,10 @@ public Task<object> ReadFirstOrDefaultAsync(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
Task
<
object
>
ReadSingleAsync
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -102,8 +97,10 @@ public Task<object> ReadSingleAsync(Type type)
...
@@ -102,8 +97,10 @@ public Task<object> ReadSingleAsync(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
Task
<
object
>
ReadSingleOrDefaultAsync
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -111,44 +108,35 @@ public Task<object> ReadSingleOrDefaultAsync(Type type)
...
@@ -111,44 +108,35 @@ public Task<object> ReadSingleOrDefaultAsync(Type type)
}
}
/// <summary>
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
/// </summary>
public
Task
<
IEnumerable
<
T
>>
ReadAsync
<
T
>(
bool
buffered
=
true
)
/// <typeparam name="T">The type to read.</typeparam>
{
/// <param name="buffered">Whether the results should be buffered in memory.</param>
return
ReadAsyncImpl
<
T
>(
typeof
(
T
),
buffered
);
public
Task
<
IEnumerable
<
T
>>
ReadAsync
<
T
>(
bool
buffered
=
true
)
=>
ReadAsyncImpl
<
T
>(
typeof
(
T
),
buffered
);
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
Task
<
T
>
ReadFirstAsync
<
T
>()
/// <typeparam name="T">The type to read.</typeparam>
{
public
Task
<
T
>
ReadFirstAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
First
);
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
First
);
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
Task
<
T
>
ReadFirstOrDefaultAsync
<
T
>()
/// <typeparam name="T">The type to read.</typeparam>
{
public
Task
<
T
>
ReadFirstOrDefaultAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
Task
<
T
>
ReadSingleAsync
<
T
>()
/// <typeparam name="T">The type to read.</typeparam>
{
public
Task
<
T
>
ReadSingleAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
Single
);
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
Single
);
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
Task
<
T
>
ReadSingleOrDefaultAsync
<
T
>()
/// <typeparam name="T">The type to read.</typeparam>
{
public
Task
<
T
>
ReadSingleOrDefaultAsync
<
T
>()
=>
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
return
ReadRowAsyncImpl
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
}
private
async
Task
NextResultAsync
()
private
async
Task
NextResultAsync
()
{
{
...
@@ -186,11 +174,11 @@ private Task<IEnumerable<T>> ReadAsyncImpl<T>(Type type, bool buffered)
...
@@ -186,11 +174,11 @@ private Task<IEnumerable<T>> ReadAsyncImpl<T>(Type type, bool buffered)
IsConsumed
=
true
;
IsConsumed
=
true
;
if
(
buffered
&&
reader
is
DbDataReader
)
if
(
buffered
&&
reader
is
DbDataReader
)
{
{
return
ReadBufferedAsync
<
T
>(
gridIndex
,
deserializer
.
Func
,
typedIdentity
);
return
ReadBufferedAsync
<
T
>(
gridIndex
,
deserializer
.
Func
);
}
}
else
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
if
(
buffered
)
result
=
result
.
ToList
();
// for the "not a DbDataReader" scenario
return
Task
.
FromResult
(
result
);
return
Task
.
FromResult
(
result
);
}
}
...
@@ -201,7 +189,7 @@ private Task<T> ReadRowAsyncImpl<T>(Type type, Row row)
...
@@ -201,7 +189,7 @@ private Task<T> ReadRowAsyncImpl<T>(Type type, Row row)
if
(
reader
is
DbDataReader
dbReader
)
return
ReadRowAsyncImplViaDbReader
<
T
>(
dbReader
,
type
,
row
);
if
(
reader
is
DbDataReader
dbReader
)
return
ReadRowAsyncImplViaDbReader
<
T
>(
dbReader
,
type
,
row
);
// no async API available; use non-async and fake it
// 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
)
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
...
@@ -235,7 +223,7 @@ private async Task<T> ReadRowAsyncImplViaDbReader<T>(DbDataReader reader, Type t
return
result
;
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
try
{
{
...
...
Dapper/SqlMapper.GridReader.cs
View file @
9b98d3df
...
@@ -26,73 +26,73 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity, I
...
@@ -26,73 +26,73 @@ internal GridReader(IDbCommand command, IDataReader reader, Identity identity, I
}
}
/// <summary>
/// <summary>
/// Read the next grid of results, returned as a dynamic object
/// Read the next grid of results, returned as a dynamic object
.
/// </summary>
/// </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>
/// <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
)
=>
public
IEnumerable
<
dynamic
>
Read
(
bool
buffered
=
true
)
=>
ReadImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
ReadImpl
<
dynamic
>(
typeof
(
DapperRow
),
buffered
);
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadFirst
()
=>
public
dynamic
ReadFirst
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
First
);
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadFirstOrDefault
()
=>
public
dynamic
ReadFirstOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
FirstOrDefault
);
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadSingle
()
=>
public
dynamic
ReadSingle
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
Single
);
/// <summary>
/// <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>
/// </summary>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
/// <remarks>Note: the row can be accessed via "dynamic", or by casting to an IDictionary<string,object></remarks>
public
dynamic
ReadSingleOrDefault
()
=>
public
dynamic
ReadSingleOrDefault
()
=>
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
ReadRow
<
dynamic
>(
typeof
(
DapperRow
),
Row
.
SingleOrDefault
);
/// <summary>
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
/// </summary>
public
IEnumerable
<
T
>
Read
<
T
>(
bool
buffered
=
true
)
=>
/// <typeparam name="T">The type to read.</typeparam>
ReadImpl
<
T
>(
typeof
(
T
),
buffered
);
/// <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>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
T
ReadFirst
<
T
>()
=
>
/// <typeparam name="T">The type to read.</typeparam
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
First
);
public
T
ReadFirst
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
First
);
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
T
ReadFirstOrDefault
<
T
>()
=
>
/// <typeparam name="T">The type to read.</typeparam
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
public
T
ReadFirstOrDefault
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
FirstOrDefault
);
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
T
ReadSingle
<
T
>()
=
>
/// <typeparam name="T">The type to read.</typeparam
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
Single
);
public
T
ReadSingle
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
Single
);
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </summary>
public
T
ReadSingleOrDefault
<
T
>()
=
>
/// <typeparam name="T">The type to read.</typeparam
>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
public
T
ReadSingleOrDefault
<
T
>()
=>
ReadRow
<
T
>(
typeof
(
T
),
Row
.
SingleOrDefault
);
/// <summary>
/// <summary>
/// Read the next grid of results
/// Read the next grid of results
.
/// </summary>
/// </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
)
public
IEnumerable
<
object
>
Read
(
Type
type
,
bool
buffered
=
true
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -100,8 +100,10 @@ public IEnumerable<object> Read(Type type, bool buffered = true)
...
@@ -100,8 +100,10 @@ public IEnumerable<object> Read(Type type, bool buffered = true)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
object
ReadFirst
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -109,8 +111,10 @@ public object ReadFirst(Type type)
...
@@ -109,8 +111,10 @@ public object ReadFirst(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
object
ReadFirstOrDefault
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -118,8 +122,10 @@ public object ReadFirstOrDefault(Type type)
...
@@ -118,8 +122,10 @@ public object ReadFirstOrDefault(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
object
ReadSingle
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -127,8 +133,10 @@ public object ReadSingle(Type type)
...
@@ -127,8 +133,10 @@ public object ReadSingle(Type type)
}
}
/// <summary>
/// <summary>
/// Read an individual row of the next grid of results
/// Read an individual row of the next grid of results
.
/// </summary>
/// </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
)
public
object
ReadSingleOrDefault
(
Type
type
)
{
{
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
if
(
type
==
null
)
throw
new
ArgumentNullException
(
nameof
(
type
));
...
@@ -150,7 +158,7 @@ private IEnumerable<T> ReadImpl<T>(Type type, bool buffered)
...
@@ -150,7 +158,7 @@ private IEnumerable<T> ReadImpl<T>(Type type, bool buffered)
cache
.
Deserializer
=
deserializer
;
cache
.
Deserializer
=
deserializer
;
}
}
IsConsumed
=
true
;
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
;
return
buffered
?
result
.
ToList
()
:
result
;
}
}
...
@@ -174,10 +182,12 @@ private T ReadRow<T>(Type type, Row row)
...
@@ -174,10 +182,12 @@ private T ReadRow<T>(Type type, Row row)
cache
.
Deserializer
=
deserializer
;
cache
.
Deserializer
=
deserializer
;
}
}
object
val
=
deserializer
.
Func
(
reader
);
object
val
=
deserializer
.
Func
(
reader
);
if
(
val
==
null
||
val
is
T
)
if
(
val
==
null
||
val
is
T
)
{
{
result
=
(
T
)
val
;
result
=
(
T
)
val
;
}
else
{
}
else
{
var
convertToType
=
Nullable
.
GetUnderlyingType
(
type
)
??
type
;
var
convertToType
=
Nullable
.
GetUnderlyingType
(
type
)
??
type
;
result
=
(
T
)
Convert
.
ChangeType
(
val
,
convertToType
,
CultureInfo
.
InvariantCulture
);
result
=
(
T
)
Convert
.
ChangeType
(
val
,
convertToType
,
CultureInfo
.
InvariantCulture
);
}
}
...
@@ -236,8 +246,14 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
...
@@ -236,8 +246,14 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
}
}
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
.
/// </summary>
/// </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
)
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
);
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
...
@@ -245,8 +261,15 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
}
}
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
.
/// </summary>
/// </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
)
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
);
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
...
@@ -256,6 +279,14 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
/// </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
)
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
);
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
...
@@ -265,6 +296,15 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
/// </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
)
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
);
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
...
@@ -274,6 +314,16 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
/// </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
)
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
);
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
...
@@ -283,6 +333,17 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
/// </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
)
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
);
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
...
@@ -292,13 +353,18 @@ private IEnumerable<TReturn> MultiReadInternal<TReturn>(Type[] types, Func<objec
/// <summary>
/// <summary>
/// Read multiple objects from a single record set on the grid
/// Read multiple objects from a single record set on the grid
/// </summary>
/// </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
)
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
;
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
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