Skip to content

Commit b2e3d44

Browse files
committed
Aggiunta classe paginazione
1 parent 950f33d commit b2e3d44

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace ClassLibrary.EFCore.Interfaces;
2+
3+
/// <summary>
4+
/// Represents a paginated result set.
5+
/// </summary>
6+
/// <typeparam name="T">The type of the items in the result set.</typeparam>
7+
public class PaginatedResult<T>
8+
{
9+
/// <summary>
10+
/// Gets or sets the total number of items.
11+
/// </summary>
12+
public int TotalItems { get; set; }
13+
14+
/// <summary>
15+
/// Gets or sets the size of each page.
16+
/// </summary>
17+
public int PageSize { get; set; }
18+
19+
/// <summary>
20+
/// Gets or sets the current page number.
21+
/// </summary>
22+
public int CurrentPage { get; set; }
23+
24+
/// <summary>
25+
/// Gets the total number of pages.
26+
/// </summary>
27+
public int TotalPages => (int)Math.Ceiling(TotalItems / (double)PageSize);
28+
29+
/// <summary>
30+
/// Gets or sets the items in the current page.
31+
/// </summary>
32+
public List<T> Items { get; set; }
33+
34+
/// <summary>
35+
/// Initializes a new instance of the <see cref="PaginatedResult{T}"/> class.
36+
/// </summary>
37+
public PaginatedResult()
38+
{
39+
Items = [];
40+
}
41+
}

0 commit comments

Comments
 (0)