Skip to content

Commit

Permalink
Add generic type constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
sunecko committed May 14, 2024
1 parent 665a16d commit 5baee71
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static class PaginationExtensions
/// <param name="pageNumber">The page number to retrieve.</param>
/// <param name="pageSize">The page size (number of items per page).</param>
/// <returns>A paginated response containing the items on the requested page and pagination information.</returns>
public static PaginatedResponse<T> ToPaginatedResult<T>(this IEnumerable<T> source, int pageNumber, int pageSize)
public static PaginatedResponse<T> ToPaginatedResult<T>(this IEnumerable<T> source, int pageNumber, int pageSize) where T : class
{
var enumerable = source as IQueryable<T> ?? source.AsQueryable();
var items = enumerable.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
Expand Down
2 changes: 1 addition & 1 deletion src/TemplateFastEndpoints.API/Utils/PaginatedResponse.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace TemplateFastEndpoints.API.Utils;

public class PaginatedResponse<T>
public class PaginatedResponse<T> where T : class
{
public PaginatedResponse(IEnumerable<T> data, int pageNumber, int pageSize,int totalPages, int totalRecords)
{
Expand Down

0 comments on commit 5baee71

Please sign in to comment.