Collate.NET 1.8.0

dotnet add package Collate.NET --version 1.8.0                
NuGet\Install-Package Collate.NET -Version 1.8.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="Collate.NET" Version="1.8.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Collate.NET --version 1.8.0                
#r "nuget: Collate.NET, 1.8.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 Collate.NET as a Cake Addin
#addin nuget:?package=Collate.NET&version=1.8.0

// Install Collate.NET as a Cake Tool
#tool nuget:?package=Collate.NET&version=1.8.0                

Collate.NET

Filtering, sorting and paging extensions for .NET IQueryable collections.

Enables convenient server-side dynamic queries via Entity Framework, especially useful when working with dynamic grid controls, like Kendo UI Grid and DevExpress, where you don't want to have to implement individual filtering and sorting for each field in the data which might be sorted or filtered on.

Entity Framework

Usage

Let's say you have an MVC controller which accepts requests from a grid control:

using Collate.Implementation;

public UserController : Controller
{
	public ActionResult GetItems(int pageNumber, int pageSize, string sortField, string sortDirection, string filterField, string filterValue)
	{
		var request = new PageAndFilterAndSortRequest
		{
			PageNumber = pageNumber,
			PageSize = pageSize,
			Sorts = new ISort[]
			{
				new Sort
				{
					Field = sortField,
					Direction = (sortDirection == "asc")
						? SortDirection.Ascending
						: SortDirection.Descending
				}
			},
			Filters = new IFilter[]
			{
				new Filter
				{
					Field = filterField,
					Operator = FilterOperator.Contains,
					Value = filterValue
				}
			}
		};

		IList<User> data;

		using (var dbContext = new MyDataContext())
		{
			data = dbContext.Users
				.Filter(request)
				.Sort(request)
				.Page(request)
				.ToList();
		}

		return Json(data, JsonRequestBehavior.AllowGet);
	}
}

This way, all the control over what field(s) to filter and sort by are in the hands of the client, as well as controlling the page and page size of the data to be viewed, and yet all the filtering is done efficiently since Entity Framework will translate the IQueryable expression into a SQL query, and all the filtering, sorting and paging will be done in-database, and the response will be just the data that is needed to show the expected data in the grid.

This is also useful for N-Tier applications where you don't want to go the nuclear option and enable odata all the way up and down the pipeline. By impelmenting a few simple interfaces you can enable performant filtering and sorting in data-heavy applications without needing to re-architect your entire application.

Please refer to the Tests project within the solution for more usage examples.

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.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.

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.8.0 3,946 12/8/2023
1.7.0 83 12/8/2023
1.6.0 63,294 3/27/2020
1.5.0 498 3/27/2020
1.4.0 794 10/10/2019
1.3.2 26,798 11/8/2018
1.3.1 4,263 8/9/2018
1.2.0 928 6/16/2018
1.1.0 2,209 3/13/2018
1.0.2 982 3/12/2018
1.0.1 980 3/12/2018
1.0.0 856 3/11/2018

Adds support multi-level navigation sorts, and automatic navigation sort by using dotted property names (e.g. "Album.Artist.Name").