EFCorePaging.Offset 1.0.3

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package EFCorePaging.Offset --version 1.0.3
                    
NuGet\Install-Package EFCorePaging.Offset -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="EFCorePaging.Offset" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EFCorePaging.Offset" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="EFCorePaging.Offset" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add EFCorePaging.Offset --version 1.0.3
                    
#r "nuget: EFCorePaging.Offset, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package EFCorePaging.Offset@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=EFCorePaging.Offset&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=EFCorePaging.Offset&version=1.0.3
                    
Install as a Cake Tool

EFCorePaging.Offset

Offset-based pagination for Entity Framework Core using efficient Skip/Take queries optimized for modern data grid components.

Features

  • ✅ Offset Pagination: Standard Skip/Take pattern for positional page navigation
  • ✅ Flexible Sorting: Multi-field sorting with ascending/descending support
  • ✅ Advanced Filtering: Extensible filtering framework with multiple operators
  • ✅ Performance Optimized: Lightweight queries designed to maintain efficient database execution plans
  • ✅ UI Component Compatible: Works seamlessly with PrimeNG, Kendo UI, and other modern data grids

Installation

dotnet add package EFCorePaging.Offset

Quick Start

Basic Usage

using EFCorePaging.Offset;
using EFCorePaging.Offset.Data;

// Create a paged request
var request = new PagedRequest 
{
    Skip = 0,           // Number of records to skip
    PageSize = 20,      // Records per page
    SortBy = "LastName" // Sort by property name
};

// Apply to your queryable
var query = dbContext.Users.AsQueryable();
var sortedQuery = query.ApplySorting(request.SortBy);

// Skip and take for pagination
var pagedQuery = sortedQuery.Skip(request.Skip).Take(request.PageSize);

// Execute and get results
var items = await pagedQuery.ToListAsync();
var totalCount = await query.CountAsync();

// Return paginated response
var response = new PagedResponse<User>(items, totalCount);

Advanced Sorting

Sort by multiple fields with mixed directions:

var request = new PagedRequest 
{
    SortBy = "Department asc, LastName desc, FirstName asc",
    Skip = 0,
    PageSize = 20
};

var sorted = dbContext.Users.ApplySorting(request.SortBy);

With Filtering

var request = new PagedRequest 
{
    Skip = 0,
    PageSize = 20,
    SortBy = "LastName",
    Filters = new List<FilterRequest>
    {
        new FilterRequest 
        { 
            Field = "Department", 
            Operator = "equals", 
            Value = "Sales" 
        }
    },
    GlobalFilterOperator = FilterOperator.All
};

var query = dbContext.Users.AsQueryable();
// Apply filters (filtering logic handled by EFCorePaging.Common)
var filtered = query.ApplySorting(request.SortBy);
var paged = filtered.Skip(request.Skip).Take(request.PageSize);

API Reference

PagedRequest

Configuration object for pagination requests.

Property Type Default Description
Skip int 0 Number of records to skip
PageSize int 20 Records per page
SortBy string "" Comma-separated sort fields (supports asc/desc modifiers)
DefaultSortDirection SortDirection Ascending Default sort direction when not specified
GlobalFilterOperator FilterOperator All How to combine multiple filters
Filters List<FilterRequest> [] Collection of filters to apply

PagedResponse<T>

Result container for paginated data.

Property Type Description
Values T[] The records returned for the current page
TotalCount int Total number of records matching the filter criteria

QueryableOffsetExtensions

Extension methods for IQueryable<T>.

ApplySorting<T>
public static IQueryable<T> ApplySorting<T>(
    this IQueryable<T> query, 
    string sortBy, 
    SortDirection defaultDirection = SortDirection.Ascending, 
    Dictionary<string, string>? propertyMap = null)

Applies dynamic sorting to a queryable.

Parameters:

  • query: The queryable to sort
  • sortBy: Comma-separated property names with optional asc/desc modifiers (e.g., "LastName desc, FirstName asc")
  • defaultDirection: Default sort direction for fields without explicit modifiers
  • propertyMap: Optional mapping from DTO property names to Entity property names

Returns: Sorted IQueryable<T>

Throws:

  • ArgumentException: If a property in sortBy is not found on type T

Performance Considerations

  • Offset pagination is best suited for smaller result sets or datasets with indexed sort columns
  • For very large datasets (1M+ records), consider cursor-based pagination for position-based navigation
  • Ensure your sort columns are properly indexed in the database
  • Use projection to select only needed columns before Skip and Take operations

Property Mapping

For DTO-to-Entity property mapping, provide a mapping dictionary:

var propertyMap = new Dictionary<string, string>
{
    { "FullName", "LastName" },
    { "Department", "Dept" }
};

var sorted = query.ApplySorting(request.SortBy, propertyMap: propertyMap);

License

This project is licensed under the MIT License - see the LICENSE file for details.

Repository

github.com/Dacke/EFCorePaging

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated