Skip to content

Commit

Permalink
Pagination<T> extends IEnumerable<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
SitholeWB committed Jul 21, 2024
1 parent c93f13a commit faa7ad0
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion Pagination.EntityFrameworkCore.Extensions/Pagination.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Pagination.EntityFrameworkCore.Extensions
{
public class Pagination<T>
public class Pagination<T> : IEnumerable<T>
{
public long TotalItems { get; set; }
public int CurrentPage { get; set; }
Expand All @@ -30,6 +31,16 @@ public Pagination(Pagination<T> pagination)
Results = pagination.Results;
}

IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return Results.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return Results.GetEnumerator();
}

public Pagination(IEnumerable<T> results, long totalItems, int page = 1, int limit = 10, bool applyPageAndLimitToResults = false)
{
if (page <= 0)
Expand Down

0 comments on commit faa7ad0

Please sign in to comment.