EDennis.NetCore.LinqTools 1.3.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package EDennis.NetCore.LinqTools --version 1.3.0                
NuGet\Install-Package EDennis.NetCore.LinqTools -Version 1.3.0                
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="EDennis.NetCore.LinqTools" Version="1.3.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.3.0                
#r "nuget: EDennis.NetCore.LinqTools, 1.3.0"                
#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.
// Install EDennis.NetCore.LinqTools as a Cake Addin
#addin nuget:?package=EDennis.NetCore.LinqTools&version=1.3.0

// Install EDennis.NetCore.LinqTools as a Cake Tool
#tool nuget:?package=EDennis.NetCore.LinqTools&version=1.3.0                

EDennis.NetCore.LinqTools

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

The Full Filtering/Sorting/Paging Spec

The full specification for filtering, sorting, and paging is represented by a simple, JSON-friendly hierarchical structure. The library also supports a more simplified spec for query-string processing (see below).

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.

The Simplified Filtering/Sorting/Paging Spec Using a Query String

The library also supports a Contoso-University-Project-inspired spec for query-string processing of filtering, sorting, and paging. Filtering is specified by a searchString query parameter (which uses the Contains operation). Sorting is specified by a sortOrder query parameter. The value of the sortOrder parameter is the name of the field to sort on, with an optional "_desc" suffix. (There is a constructor overload for mapping sortOrder parameter values to field names and sort direction, just in case this kind of flexibility is required.) Paging is accomplished with pageNumber and pageSize query parameters.

Other Examples

The test project in this solution includes examples of filtering, sorting, and paging, using the full (JSON body) spec and the simplified (query string) spec.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 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
1.3.2 608 9/2/2019
1.3.1 519 9/2/2019
1.3.0 492 9/2/2019
1.2.1 527 6/25/2019
1.2.0 518 6/24/2019
1.1.0 512 6/24/2019
1.0.0 493 6/22/2019

Adapted https://github.com/dotlattice/LatticeUtils to add selection of properties (projection) to options.