项目作者: AlexanderKrutov

项目描述 :
.Net library for clever processing of requests from datatables.net jQuery plugin on the server side (ASP.NET, Nancy or any other web server).
高级语言: C#
项目地址: git://github.com/AlexanderKrutov/DataTables.Queryable.git
创建时间: 2016-11-18T21:05:18Z
项目社区:https://github.com/AlexanderKrutov/DataTables.Queryable

开源协议:MIT License

下载


DataTables.Queryable

What is it?

It is a .Net library for clever processing of requests from datatables.net jQuery plugin on the server side (ASP.NET, Nancy or any other web server).

The library significantly reduces boilerplate code and helps to avoid writing same logic of parsing requests for different model types.

Installation NuGet Status

  1. PM> Install-Package DataTables.Queryable

How to use it?

  1. // ASP.NET action handler inside a controller:
  2. public JsonResult DataTablesRequestAction()
  3. {
  4. // make a DataTablesRequest object from the incoming Http query string
  5. var request = new DataTablesRequest<Person>(Request.QueryString);
  6. using (var ctx = new DatabaseContext())
  7. {
  8. // take persons from database, apply the DataTablesRequest filter and paginate
  9. var persons = ctx.Persons.ToPagedList(request);
  10. // push back a result in JSON form applicable for datatables.net
  11. return JsonDataTable(persons);
  12. }
  13. }

Need more info? Welcome to the wiki.

How it works?

  1. DataTables.Queryable parses data from an incoming Http request and extracts related parameters (search text, columns ordering info, page number and number of records per page and etc.);
  2. Dynamically builds an expression tree from the request parameters and information about model type T using reflection;
  3. Filters provided IQueryable<T> with the expression tree.
  4. Returns query result as a PagedList<T> instance (collection of items that represents a single page of extracted data).

Take a closer look what happens inside.

Features

  • Global search, individual column search, ordering by one or many columns, pagination
  • Custom request parameters
  • Custom search predicates
  • Supports nested properties
  • Lazy data loading from provided IQueryable<T> (only filtered records will be extracted)
  • Compatible with Entity Framework

License

DataTables.Queryable is licensed under MIT license.