Kendo.DynamicLinqCore 2.2.0

Kendo.DynamicLinqCore implements server paging, filtering, sorting, grouping and aggregating to Kendo UI via Dynamic Linq for .Net Core App(1.x ~ 2.x).

Supported platforms:

- .NET Standard 1.6
- .NET Standard 2.0
- .NET Core 1.0 ~ .NET Core 1.1
- .NET Core 2.0 ~ .NET Core 2.2

There is a newer version of this package available.
See the version list below for details.
Install-Package Kendo.DynamicLinqCore -Version 2.2.0
dotnet add package Kendo.DynamicLinqCore --version 2.2.0
<PackageReference Include="Kendo.DynamicLinqCore" Version="2.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Kendo.DynamicLinqCore --version 2.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Kendo.DynamicLinqCore, 2.2.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 Kendo.DynamicLinqCore as a Cake Addin
#addin nuget:?package=Kendo.DynamicLinqCore&version=2.2.0

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

Kendo.DynamicLinqCore implements server paging, filtering, sorting, grouping and aggregating to Kendo UI via Dynamic Linq for .Net Core App(1.x ~ 2.x).

Usage

  1. Add the Kendo.DynamicLinqCore NuGet package to your project.
  2. Configure your Kendo DataSource to send its options as JSON.
parameterMap: function(options, type) {
    return JSON.stringify(options);
}
  1. Configure the schema of the dataSource.
schema: {
    data: "Data",
    total: "Total",
    aggregates: "Aggregates",
    groups: "Groups",
    errors: "Errors"
}
  1. The completed code like below.
..... Other kendo grid code .....

dataSource: {
    schema:
    {
        data: "Data",
        total: "Total",
        aggregates: "Aggregates",
        groups: "Groups",
        errors: "Errors",
        ...
    },
    transport: {
        read: {
            url: 'your read url',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            type: 'POST'
        },
        create: {
            url: 'your create url',
            dataType: "json",
            contentType: 'application/json; charset=utf-8',
            type: 'POST'
        },
        parameterMap: function (data, operation) {
            return JSON.stringify(data);
        }
    },
    error: function(e) {
        console.log(e.errors); // Your error information
        e.sender.cancelChanges();
    },
    pageSize: 20,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true,
    ...
}

..... Other kendo grid code .....
  1. Import the Kendo.DynamicLinqCore namespace.
  2. Use the ToDataSourceResult extension method to apply paging, sorting, filtering, grouping and aggregating.
using Kendo.DynamicLinqCore

[WebMethod]
public static DataSourceResult Products(int take, int skip, IEnumerable<Sort> sort, Filter filter, IEnumerable<Aggregator> aggregates, IEnumerable<Group> groups)
{
    using (var northwind = new Northwind())
    {
        return northwind.Products
               .OrderBy(p => p.ProductID) // EF requires ordering for paging                    
               .Select(p => new ProductViewModel // Use a view model to avoid serializing internal Entity Framework properties as JSON
               {
                   ProductID = p.ProductID,
                   ProductName = p.ProductName,
                   UnitPrice = p.UnitPrice,
                   UnitsInStock = p.UnitsInStock,
                   Discontinued = p.Discontinued
               })
               .ToDataSourceResult(take, skip, sort, filter, aggregates, groups);
    }
}

or from Kendo UI request

using Kendo.DynamicLinqCore

[HttpPost]
public IActionResult Products([FromBody] DataSourceRequest requestModel)
{
    using (var northwind = new Northwind())
    {
        return northwind.Products                  
               .Select(p => new ProductViewModel // Use a view model to avoid serializing internal Entity Framework properties as JSON
               {
                   ProductID = p.ProductID,
                   ProductName = p.ProductName,
                   UnitPrice = p.UnitPrice,
                   UnitsInStock = p.UnitsInStock,
                   Discontinued = p.Discontinued
               })
               .ToDataSourceResult(requestModel.Take, requestModel.Skip, requestModel.Sort, requestModel.Filter, requestModel.Aggregate, requestModel.Group);
    }
}

Known Issues

When server-side filterable options are enabled and apply a query with filter condition that contains DateTime type column, then EntityFramework Core would throw an exception System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting date and/or time from character string. The error is caused by a known issue in some old EntityFramework Core versions. The workaround is adding datetime value to the related column in DbContext. e.g.

public class MyContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        ..........

        modelBuilder.Entity<Member>().Property(x => x.UpdateTime).HasColumnType("datetime");

        ..........
    }
}

Note

Kendo.DynamicLinqCore is a reference to Ali Sarkis's Kendo.DynamicLinq.

Kendo UI Documentation

The following links are Kendo UI online docs(related to this package) and you can refer to.

More Kendo UI configuration can refer to here

Kendo.DynamicLinqCore implements server paging, filtering, sorting, grouping and aggregating to Kendo UI via Dynamic Linq for .Net Core App(1.x ~ 2.x).

Usage

  1. Add the Kendo.DynamicLinqCore NuGet package to your project.
  2. Configure your Kendo DataSource to send its options as JSON.
parameterMap: function(options, type) {
    return JSON.stringify(options);
}
  1. Configure the schema of the dataSource.
schema: {
    data: "Data",
    total: "Total",
    aggregates: "Aggregates",
    groups: "Groups",
    errors: "Errors"
}
  1. The completed code like below.
..... Other kendo grid code .....

dataSource: {
    schema:
    {
        data: "Data",
        total: "Total",
        aggregates: "Aggregates",
        groups: "Groups",
        errors: "Errors",
        ...
    },
    transport: {
        read: {
            url: 'your read url',
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            type: 'POST'
        },
        create: {
            url: 'your create url',
            dataType: "json",
            contentType: 'application/json; charset=utf-8',
            type: 'POST'
        },
        parameterMap: function (data, operation) {
            return JSON.stringify(data);
        }
    },
    error: function(e) {
        console.log(e.errors); // Your error information
        e.sender.cancelChanges();
    },
    pageSize: 20,
    serverPaging: true,
    serverFiltering: true,
    serverSorting: true,
    ...
}

..... Other kendo grid code .....
  1. Import the Kendo.DynamicLinqCore namespace.
  2. Use the ToDataSourceResult extension method to apply paging, sorting, filtering, grouping and aggregating.
using Kendo.DynamicLinqCore

[WebMethod]
public static DataSourceResult Products(int take, int skip, IEnumerable<Sort> sort, Filter filter, IEnumerable<Aggregator> aggregates, IEnumerable<Group> groups)
{
    using (var northwind = new Northwind())
    {
        return northwind.Products
               .OrderBy(p => p.ProductID) // EF requires ordering for paging                    
               .Select(p => new ProductViewModel // Use a view model to avoid serializing internal Entity Framework properties as JSON
               {
                   ProductID = p.ProductID,
                   ProductName = p.ProductName,
                   UnitPrice = p.UnitPrice,
                   UnitsInStock = p.UnitsInStock,
                   Discontinued = p.Discontinued
               })
               .ToDataSourceResult(take, skip, sort, filter, aggregates, groups);
    }
}

or from Kendo UI request

using Kendo.DynamicLinqCore

[HttpPost]
public IActionResult Products([FromBody] DataSourceRequest requestModel)
{
    using (var northwind = new Northwind())
    {
        return northwind.Products                  
               .Select(p => new ProductViewModel // Use a view model to avoid serializing internal Entity Framework properties as JSON
               {
                   ProductID = p.ProductID,
                   ProductName = p.ProductName,
                   UnitPrice = p.UnitPrice,
                   UnitsInStock = p.UnitsInStock,
                   Discontinued = p.Discontinued
               })
               .ToDataSourceResult(requestModel.Take, requestModel.Skip, requestModel.Sort, requestModel.Filter, requestModel.Aggregate, requestModel.Group);
    }
}

Known Issues

When server-side filterable options are enabled and apply a query with filter condition that contains DateTime type column, then EntityFramework Core would throw an exception System.Data.SqlClient.SqlException (0x80131904): Conversion failed when converting date and/or time from character string. The error is caused by a known issue in some old EntityFramework Core versions. The workaround is adding datetime value to the related column in DbContext. e.g.

public class MyContext : DbContext
{
    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        ..........

        modelBuilder.Entity<Member>().Property(x => x.UpdateTime).HasColumnType("datetime");

        ..........
    }
}

Note

Kendo.DynamicLinqCore is a reference to Ali Sarkis's Kendo.DynamicLinq.

Kendo UI Documentation

The following links are Kendo UI online docs(related to this package) and you can refer to.

More Kendo UI configuration can refer to here

Release Notes

1. Change the property "Group" of DataSourceResult to "Groups".
2. Add new property "Aggregate" to DataSourceRequest.
3. Fixed getting wrong grouping data in the request using aggregates in grouping configuration.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Kendo.DynamicLinqCore:

Package Downloads
Kharazmi.AspNetCore.Core
Kharazmi.AspNetCore.Core is a Lightweight and Extensible Infrastructure for provides common scenarios' solutions for ASP.NET Core applications.
Kharazmi.AspNetCore.Localization.EFCore
ASP.NET Core provides services and middleware for localizing into different languages and cultures. You can create EntityFramework core concretes as your repository.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
3.1.1 6,255 11/5/2020
3.1.0 24,787 2/11/2020
2.2.2 14,237 9/17/2019
2.2.0 2,543 7/5/2019
2.1.0 12,064 5/16/2019
2.0.2 573 4/12/2019
2.0.0 4,606 9/10/2018
1.0.5 1,080 1/4/2018
1.0.4 674 11/29/2017
1.0.3 1,203 2/6/2017
1.0.2 673 1/13/2017
1.0.1 858 12/30/2016