1
1
using System . Linq . Expressions ;
2
- using KSFramework . KSDomain . AggregatesHelper ;
3
2
using KSFramework . Pagination ;
4
3
5
4
namespace KSFramework . GenericRepository ;
6
5
7
6
/// <summary>
8
- /// Represents a generic repository interface for performing CRUD operations on entities.
7
+ /// Represents a generic repository contract for performing common data access operations on entities.
9
8
/// </summary>
10
9
/// <typeparam name="TEntity">The type of the entity.</typeparam>
11
10
public interface IGenericRepository < TEntity > where TEntity : class
12
11
{
13
12
/// <summary>
14
- /// Retrieves an entity by its identifier asynchronously .
13
+ /// Asynchronously retrieves an entity by its unique identifier .
15
14
/// </summary>
16
- /// <param name="id">The identifier of the entity.</param>
17
- /// <returns>A task that represents the asynchronous operation. The task result contains the entity if found.</returns>
15
+ /// <param name="id">The unique identifier of the entity.</param>
16
+ /// <returns>A task representing the asynchronous operation, containing the entity if found; otherwise, null .</returns>
18
17
ValueTask < TEntity ? > GetByIdAsync ( object id ) ;
19
18
20
19
/// <summary>
21
- /// Retrieves all entities asynchronously .
20
+ /// Asynchronously retrieves all entities.
22
21
/// </summary>
23
- /// <returns>A task that represents the asynchronous operation. The task result contains the collection of entities.</returns>
22
+ /// <returns>A task representing the asynchronous operation, containing a collection of all entities.</returns>
24
23
Task < IEnumerable < TEntity > > GetAllAsync ( ) ;
25
24
26
25
/// <summary>
27
- /// Retrieves a paginated list of entities asynchronously based on specified criteria .
26
+ /// Asynchronously retrieves a paginated list of entities with optional filtering and ordering .
28
27
/// </summary>
29
- /// <param name="pageIndex">The index of the page to retrieve (1-based ).</param>
30
- /// <param name="pageSize">The size of the page.</param>
31
- /// <param name="where">Optional predicate to filter the entities .</param>
32
- /// <param name="orderBy">Optional property name to order the results by.</param>
33
- /// <param name="desc">Optional flag to indicate descending order .</param>
34
- /// <returns>A task that represents the asynchronous operation. The task result contains the paginated list of entities.</returns>
28
+ /// <param name="pageIndex">The index of the page (starting from 1 ).</param>
29
+ /// <param name="pageSize">The number of items per page.</param>
30
+ /// <param name="where">Optional filter expression .</param>
31
+ /// <param name="orderBy">Optional property name to order by.</param>
32
+ /// <param name="desc">Indicates if the order should be descending .</param>
33
+ /// <returns>A task representing the asynchronous operation, containing a paginated list of entities.</returns>
35
34
Task < PaginatedList < TEntity > > GetPagedAsync ( int pageIndex , int pageSize , Expression < Func < TEntity , bool > > ? where = null , string ? orderBy = "" , bool desc = false ) ;
36
35
37
36
/// <summary>
38
- /// Retrieves a paginated list of entities synchronously based on specified criteria .
37
+ /// Synchronously retrieves a paginated list of entities with optional filtering and ordering .
39
38
/// </summary>
40
- /// <param name="pageIndex">The index of the page to retrieve (1-based ).</param>
41
- /// <param name="pageSize">The size of the page.</param>
42
- /// <param name="where">Optional predicate to filter the entities .</param>
43
- /// <param name="orderBy">Optional property name to order the results by.</param>
44
- /// <param name="desc">Optional flag to indicate descending order .</param>
39
+ /// <param name="pageIndex">The index of the page (starting from 1 ).</param>
40
+ /// <param name="pageSize">The number of items per page.</param>
41
+ /// <param name="where">Optional filter expression .</param>
42
+ /// <param name="orderBy">Optional property name to order by.</param>
43
+ /// <param name="desc">Indicates if the order should be descending .</param>
45
44
/// <returns>A paginated list of entities.</returns>
46
45
PaginatedList < TEntity > GetPaged ( int pageIndex , int pageSize , Expression < Func < TEntity , bool > > ? where = null , string ? orderBy = "" , bool desc = false ) ;
47
46
48
47
/// <summary>
49
- /// Finds entities that match the specified predicate.
48
+ /// Finds entities matching the given predicate.
50
49
/// </summary>
51
- /// <param name="predicate">The condition to filter entities .</param>
52
- /// <returns>A collection of entities that match the condition .</returns>
50
+ /// <param name="predicate">The condition to match .</param>
51
+ /// <returns>A collection of matching entities .</returns>
53
52
IEnumerable < TEntity > Find ( Expression < Func < TEntity , bool > > predicate ) ;
54
53
55
54
/// <summary>
56
- /// Retrieves a single entity that matches the specified predicate, or null if no match is found .
55
+ /// Asynchronously returns a single entity matching the given predicate, or null if none match.
57
56
/// </summary>
58
- /// <param name="predicate">The condition to filter the entity .</param>
59
- /// <returns>A task that represents the asynchronous operation. The task result contains the entity if found, otherwise null.</returns>
57
+ /// <param name="predicate">The condition to match .</param>
58
+ /// <returns>A task representing the asynchronous operation, containing a single entity or null.</returns>
60
59
Task < TEntity ? > SingleOrDefaultAsync ( Expression < Func < TEntity , bool > > predicate ) ;
61
60
62
61
/// <summary>
63
- /// Adds a new entity to the repository asynchronously .
62
+ /// Asynchronously adds an entity to the repository.
64
63
/// </summary>
65
64
/// <param name="entity">The entity to add.</param>
66
- /// <returns>A task that represents the asynchronous operation.</returns>
67
65
Task AddAsync ( TEntity entity ) ;
68
66
69
67
/// <summary>
70
- /// Adds multiple entities to the repository asynchronously .
68
+ /// Asynchronously adds multiple entities to the repository.
71
69
/// </summary>
72
- /// <param name="entities">The collection of entities to add.</param>
73
- /// <returns>A task that represents the asynchronous operation.</returns>
70
+ /// <param name="entities">The entities to add.</param>
74
71
Task AddRangeAsync ( IEnumerable < TEntity > entities ) ;
75
72
76
73
/// <summary>
@@ -82,13 +79,13 @@ public interface IGenericRepository<TEntity> where TEntity : class
82
79
/// <summary>
83
80
/// Removes multiple entities from the repository.
84
81
/// </summary>
85
- /// <param name="entities">The collection of entities to remove.</param>
82
+ /// <param name="entities">The entities to remove.</param>
86
83
void RemoveRange ( IEnumerable < TEntity > entities ) ;
87
84
88
85
/// <summary>
89
- /// Checks if any entity exists that matches the specified predicate.
86
+ /// Asynchronously checks whether any entity matches the given predicate.
90
87
/// </summary>
91
- /// <param name="predicate">The condition to check for existence .</param>
92
- /// <returns>A task that represents the asynchronous operation. The task result contains true if a matching entity exists ; otherwise, false.</returns>
88
+ /// <param name="predicate">The condition to match .</param>
89
+ /// <returns>A task representing the asynchronous operation, containing true if any entity matches ; otherwise, false.</returns>
93
90
Task < bool > IsExistValueForPropertyAsync ( Expression < Func < TEntity , bool > > predicate ) ;
94
- }
91
+ }
0 commit comments