示例#1
0
    /// <summary>
    /// Returns true when there is more data after the list.
    /// </summary>
    /// <typeparam name="T">The type of the elements of source.</typeparam>
    /// <typeparam name="T2">The type of the elements of the data.</typeparam>
    /// <param name="context">The <see cref="KeysetPaginationContext{T}"/> object.</param>
    /// <param name="data">The data list.</param>
    public static Task <bool> HasNextAsync <T, T2>(
        this KeysetPaginationContext <T> context,
        IReadOnlyList <T2> data)
        where T : class
    {
        if (data == null)
        {
            throw new ArgumentNullException(nameof(data));
        }
        if (context == null)
        {
            throw new ArgumentNullException(nameof(context));
        }

        if (!data.Any())
        {
            return(Task.FromResult(false));
        }

        // Get last item and see if there's anything after it.
        var reference = data[^ 1] !;
示例#2
0
    /// <summary>
    /// Returns true when there is more data before the list.
    /// </summary>
    /// <typeparam name="T">The type of the elements of source.</typeparam>
    /// <typeparam name="T2">The type of the elements of the data.</typeparam>
    /// <param name="context">The <see cref="KeysetPaginationContext{T}"/> object.</param>
    /// <param name="data">The data list.</param>
    public static Task <bool> HasPreviousAsync <T, T2>(
        this KeysetPaginationContext <T> context,
        IReadOnlyList <T2> data)
        where T : class
    {
        if (data == null)
        {
            throw new ArgumentNullException(nameof(data));
        }
        if (context == null)
        {
            throw new ArgumentNullException(nameof(context));
        }

        if (!data.Any())
        {
            return(Task.FromResult(false));
        }

        // Get first item and see if there's anything before it.
        var reference = data[0] !;

        return(HasAsync(context, KeysetPaginationDirection.Backward, reference));
    }