EDennis.NetCore.LinqTools 1.1.0

.NET Core 2.2
There is a newer version of this package available.
See the version list below for details.
Install-Package EDennis.NetCore.LinqTools -Version 1.1.0
dotnet add package EDennis.NetCore.LinqTools --version 1.1.0
<PackageReference Include="EDennis.NetCore.LinqTools" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add EDennis.NetCore.LinqTools --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: EDennis.NetCore.LinqTools, 1.1.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install EDennis.NetCore.LinqTools as a Cake Addin
#addin nuget:?package=EDennis.NetCore.LinqTools&version=1.1.0

// Install EDennis.NetCore.LinqTools as a Cake Tool
#tool nuget:?package=EDennis.NetCore.LinqTools&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

EDennis.NetCore.LinqTools

Dynamically applies filtering, sorting, and paging to IEnumerable, IQueryable, and DbSet objects using a JSON-friendly spec.

The Filtering/Sorting/Paging Spec

The specification for filtering, sorting, and paging is represented by a simple, JSON-friendly hierarchical structure.

Example Specification as JSON

{
   filter: 
   [
      [
         {
            property: "Name",
            operation: "Eq",
            stringValue: "AliceBlue"
         }
      ],
      [
         {
            property: "Red",
            operation: "Eq",
            stringValue: "0"
         },
         {
            property: "Blue",
            operation: "Eq",
            stringValue: "0"
         }
      ]
   ],
   sort: 
   [
      {
         property: "Red",
         direction: "Ascending"
      },
      {
         property: "Green",
         direction: "Ascending"
      }
   ],
   page: 
   {
      pageNumber: 2,
      pageSize: 3
   }
}

Filtering Spec

The filtering specification is a two-dimensional array of objects, which can be interpreted as a filter table. Each row in the filter table (an outer array element) represents an intersection (AND-ed) over one or more expression units. Each expression unit consists of a property name, and operation, and a literal value (as a string). Currently supported operations are: Eq, Lt, Le, Gt, Ge, Contains, StartsWith, and EndsWith. All filter rows are unioned (OR-ed) to provide the complete filter. This is analogous to the filtering table in the design mode of a Microsoft Access query.

In the above example, we select all objects where Name = "AliceBlue" or where both Red and Blue properties were equal to zero.

Sorting Spec

The sorting specification is a one-dimensional array of objects, where each object provides a property name and sort direction.

In the above example, we sort by Red (ascending) and then by Green (ascending)

Paging Spec

The paging specification is a single object consisting of a page number and page size.

In the above example, we return the second page, where each page holds three objects.

Other Examples

The test project in this solution includes other examples of filtering, sorting, and paging.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
Compatible target framework(s)
Additional computed target framework(s)
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
1.3.2 381 9/2/2019
1.3.1 331 9/2/2019
1.3.0 317 9/2/2019
1.2.1 354 6/25/2019
1.2.0 349 6/24/2019
1.1.0 351 6/24/2019
1.0.0 336 6/22/2019

Now supports comma-delimited lists within each filter unit