-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIExecuteReader.cs
91 lines (82 loc) · 4.22 KB
/
IExecuteReader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
namespace Open.Database.Extensions;
/// <summary>
/// Common interface used for expressive commands when dealing with a data reader.
/// </summary>
public interface IExecuteReader
{
/// <summary>
/// The cancellation token to use with supported methods.
/// </summary>
CancellationToken CancellationToken { get; }
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for the data reader.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
void ExecuteReader(Action<IDataReader> handler, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a transform function.
/// </summary>
/// <typeparam name="T">The return type of the transform function.</typeparam>
/// <param name="transform">The transform function for each IDataRecord.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
/// <returns>The result of the transform.</returns>
T ExecuteReader<T>(Func<IDataReader, T> transform, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for the data reader.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
ValueTask ExecuteReaderAsync(Func<IDataReader, ValueTask> handler, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="transform">The transform function for each IDataRecord.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
ValueTask<T> ExecuteReaderAsync<T>(Func<IDataReader, ValueTask<T>> transform, CommandBehavior behavior = CommandBehavior.Default);
}
/// <summary>
/// Common interface used for expressive commands when dealing with a data reader.
/// </summary>
/// <typeparam name="TReader">The type of the data reader.</typeparam>
public interface IExecuteReader<out TReader> : IExecuteReader
where TReader : IDataReader
{
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for the data reader.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
void ExecuteReader(Action<TReader> handler, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a transform function.
/// </summary>
/// <typeparam name="T">The return type of the transform function.</typeparam>
/// <param name="transform">The transform function for each IDataRecord.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
/// <returns>The result of the transform.</returns>
T ExecuteReader<T>(Func<TReader, T> transform, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for the data reader.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
ValueTask ExecuteReaderAsync(Func<TReader, ValueTask> handler, CommandBehavior behavior = CommandBehavior.Default);
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for the data reader.</param>
/// <param name="behavior">The command behavior for once the command the reader is complete.</param>
ValueTask<T> ExecuteReaderAsync<T>(Func<TReader, ValueTask<T>> handler, CommandBehavior behavior = CommandBehavior.Default);
}
/// <inheritdoc />
public interface IExecuteReaderAsync : IExecuteReader
{
/// <summary>
/// Indicates if reader.ReadAsync() will be used in favor of reader.Read().
/// </summary>
bool UseAsyncRead { get; }
}
/// <inheritdoc />
public interface IExecuteReaderAsync<TReader> : IExecuteReaderAsync, IExecuteReader<TReader>
where TReader : IDataReader;