sqlkata / querybuilder

SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
https://sqlkata.com
MIT License
3.09k stars 499 forks source link

Possible documentation error #701

Open nester-a opened 9 months ago

nester-a commented 9 months ago

I think I found an error in your documentation in the "data pagination" section.

// users is of type `PaginationResult`
var users = query.Paginate(1, 10);

foreach(var user in users.Each)
{
    Console.WriteLine($"Id: {user.Id}, Name: {user.Name}");
}

In this example, it means that we can iterate over the returned data.

But this example incorrect. In fact users.Each returns PaginationIterator<T> which has this enumerator:

public IEnumerator<PaginationResult<T>> GetEnumerator()
        {
            CurrentPage = FirstPage;
            yield return CurrentPage;
            while (CurrentPage.HasNext)
            {
                CurrentPage = CurrentPage.Next();
                yield return CurrentPage;
            }
        }

Is this a mistake in the documentation, or am I just misunderstanding it?