Collate.NET 1.3.2

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.

Install-Package Collate.NET -Version 1.3.2
dotnet add package Collate.NET --version 1.3.2
<PackageReference Include="Collate.NET" Version="1.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Collate.NET --version 1.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

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.

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.

Release Notes

Adds SourceLink support

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.3.2 3,480 11/8/2018
1.3.1 3,426 8/9/2018
1.2.0 245 6/16/2018
1.1.0 1,493 3/13/2018
1.0.2 285 3/12/2018
1.0.1 243 3/12/2018
1.0.0 221 3/11/2018