This repository was archived by the owner on Apr 12, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIAsyncReadonlyRepo.cs
More file actions
executable file
·143 lines (127 loc) · 6.14 KB
/
IAsyncReadonlyRepo.cs
File metadata and controls
executable file
·143 lines (127 loc) · 6.14 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// // ***********************************************************************
// // Solution : Inno.Api.v2
// // Assembly : FCS.Lib.Utility
// // Filename : IAsyncReadonlyRepo.cs
// // Created : 2025-01-03 14:01
// // Last Modified By : dev
// // Last Modified On : 2025-01-04 12:01
// // ***********************************************************************
// // <copyright company="Frede Hundewadt">
// // Copyright (C) 2010-2025 Frede Hundewadt
// // This program is free software: you can redistribute it and/or modify
// // it under the terms of the GNU Affero General Public License as
// // published by the Free Software Foundation, either version 3 of the
// // License, or (at your option) any later version.
// //
// // This program is distributed in the hope that it will be useful,
// // but WITHOUT ANY WARRANTY; without even the implied warranty of
// // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// // GNU Affero General Public License for more details.
// //
// // You should have received a copy of the GNU Affero General Public License
// // along with this program. If not, see [https://www.gnu.org/licenses]
// // </copyright>
// // <summary></summary>
// // ***********************************************************************
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
namespace FCS.Lib.Utility;
/// <summary>
/// Provides an asynchronous read-only repository interface for accessing entities of type
/// <typeparamref name="TEntity" />.
/// </summary>
/// <typeparam name="TEntity">The type of the entity managed by the repository. Must be a reference type.</typeparam>
public interface IAsyncReadonlyRepo<TEntity> where TEntity : class
{
/// <summary>
/// Retrieves all entities of type <typeparamref name="TEntity" /> as an <see cref="IQueryable{T}" />.
/// </summary>
/// <returns>
/// An <see cref="IQueryable{T}" /> representing all entities of type <typeparamref name="TEntity" /> in the
/// repository.
/// </returns>
IQueryable<TEntity> All();
/// <summary>
/// Asynchronously retrieves a list of entities that match the specified predicate.
/// </summary>
/// <param name="predicate">
/// An expression to filter the entities.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains a list of entities
/// that satisfy the specified predicate.
/// </returns>
Task<IList<TEntity>> AllAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Determines asynchronously whether any entities in the repository satisfy the specified condition.
/// </summary>
/// <param name="predicate">
/// An expression to test each entity for a condition.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains <c>true</c> if any entities satisfy the
/// condition specified by <paramref name="predicate" />; otherwise, <c>false</c>.
/// </returns>
Task<bool> AnyAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Asynchronously finds a single entity of type <typeparamref name="TEntity" /> that matches the specified
/// <paramref name="predicate" />.
/// </summary>
/// <param name="predicate">
/// An expression to test each entity for a condition.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the entity of type
/// <typeparamref name="TEntity" />
/// that matches the specified <paramref name="predicate" />, or <c>null</c> if no such entity is found.
/// </returns>
/// <exception cref="ArgumentNullException">
/// Thrown if the <paramref name="predicate" /> is <c>null</c>.
/// </exception>
Task<TEntity> FindAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Asynchronously retrieves the first entity of type <typeparamref name="TEntity" />
/// that satisfies the specified <paramref name="predicate" />.
/// </summary>
/// <param name="predicate">
/// An expression to test each entity for a condition.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains
/// the first entity that matches the specified condition.
/// </returns>
/// <exception cref="InvalidOperationException">
/// Thrown if no entity satisfies the condition specified by <paramref name="predicate" />.
/// </exception>
Task<TEntity> FirstAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Asynchronously retrieves the first entity that matches the specified predicate or a default value if no such entity
/// is found.
/// </summary>
/// <param name="predicate">
/// An expression to test each entity for a condition.
/// </param>
/// <returns>
/// A task that represents the asynchronous operation. The task result contains the first entity that matches the
/// predicate,
/// or the default value for the entity type if no such entity is found.
/// </returns>
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// </summary>
/// <param name="predicate"></param>
/// <returns></returns>
bool Any(Expression<Func<TEntity, bool>> predicate);
/// <summary>
/// Retrieves an entity of type <typeparamref name="TEntity" /> by its unique identifier.
/// </summary>
/// <param name="id">The unique identifier of the entity to retrieve.</param>
/// <returns>
/// The entity of type <typeparamref name="TEntity" /> that matches the specified identifier, or <c>null</c> if no
/// such entity exists.
/// </returns>
TEntity GetById(string id);
}