-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathIExecuteCommand.cs
70 lines (62 loc) · 2.69 KB
/
IExecuteCommand.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
namespace Open.Database.Extensions;
/// <summary>
/// Common interface used for expressive commands.
/// </summary>
public interface IExecuteCommand
{
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="action">The handler function for each IDataRecord.</param>
void Execute(Action<IDbCommand> action);
/// <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>
/// <returns>The result of the transform.</returns>
T Execute<T>(Func<IDbCommand, T> transform);
/// <summary>
/// Asynchronously executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for each IDataRecord.</param>
ValueTask ExecuteAsync(Func<IDbCommand, ValueTask> handler);
/// <summary>
/// Asynchronously 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>
/// <returns>The result of the transform.</returns>
ValueTask<T> ExecuteAsync<T>(Func<IDbCommand, ValueTask<T>> transform);
}
/// <summary>
/// Common interface used for expressive commands.
/// </summary>
public interface IExecuteCommand<out TCommand> : IExecuteCommand
where TCommand : IDbCommand
{
/// <summary>
/// Executes a reader on a command with a handler function.
/// </summary>
/// <param name="action">The handler function for each IDataRecord.</param>
void Execute(Action<TCommand> action);
/// <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>
/// <returns>The result of the transform.</returns>
T Execute<T>(Func<TCommand, T> transform);
/// <summary>
/// Asynchronously executes a reader on a command with a handler function.
/// </summary>
/// <param name="handler">The handler function for each IDataRecord.</param>
ValueTask ExecuteAsync(Func<TCommand, ValueTask> handler);
/// <summary>
/// Asynchronously 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>
/// <returns>The result of the transform.</returns>
ValueTask<T> ExecuteAsync<T>(Func<TCommand, ValueTask<T>> transform);
}