New to Telerik UI for ASP.NET Core? Start a free 30-day trial

ASP.NET Core DataSource Overview

Updated on Nov 16, 2026

The Telerik UI DataSource TagHelper and HtmlHelper for ASP.NET Core are server-side wrappers for the Kendo UI for jQuery DataSource.

The DataSource is an abstraction for using local data or remote data. In most cases, the DataSource definition is declared as part of the configurations for the Telerik UI helpers. The standalone DataSource component is suitable for scenarios that require a shared data source.

Initialize the DataSource

The following example demonstrates how to define the DataSource. You can access the DataSource instance by Name() on the client and use the API methods and events of the Kendo UI for jQuery DataSource widget.

Razor
    @(Html.Kendo().DataSource<OrderViewModel>()
        .Name("myDataSource")
        .Ajax(d=>d.Read(r => r.Action("ReadOrders", "Home")))
    )

    <script>
        $(document).ready(function () {
            myDataSource.read(); // A POST request will be sent to the HomeController "ReadOrders" action.
        });
    </script>  
  • If your data is IQueryable<T> returned by a LINQ-enabled provider—Entity Framework, LINQ to SQL, Telerik OpenAccess, NHibernate or other—the LINQ expressions, created by the ToDataSourceResult method, are converted to SQL and executed by the database server.
  • Use the ToDataSourceResult() method to page, sort, filter, and group the collection that is passed to it. If this collection is already paged, the method returns an empty result.
  • As of the R1 2017 SP1 release, you can use the ToDataSourceResultAsync extension method to provide the asynchronous functionality of ToDataSourceResult by leveraging the async and await features of the .NET Framework.
  • If impersonation is enabled, use the ToDataSourceResultAsync extension method with only one thread in your ASP.NET application. If you create a new thread, the impersonation in the newly created child thread decreases because, by default, all newly created child threads in ASP.NET run under the ASP.NET identity of the worker process. To change this behavior, explicitly impersonate the current identity within the code of the child thread.

Default Ordering for Some Query Providers

When the DataSourceRequest has no sort descriptors, ToDataSourceResult() adds a temporary sort for query providers that Kendo recognizes as requiring an OrderBy before paging. The fallback uses the first property with a predefined .NET type on the query element type. It does not check whether that property is mapped by the query provider, so an unmapped property can cause query translation to fail.

The fallback is provider-dependent and may not apply to every Entity Framework provider. It is also applied with OrderBy, which can replace ordering already applied to the query. If you need a specific sort, configure a sort descriptor as described in DataSource Sorting; do not rely on ordering the query before calling ToDataSourceResult() when the request has no sort descriptors.

To use DataSourceRequest and ToDataSourceResult() with the DataSource HtmlHelper, add the following namespaces with using directives in the Controller:

C#
    using Kendo.Mvc.Extensions;
    using Kendo.Mvc.UI;

To use DataSourceRequest and ToDataSourceResult() with the DataSource TagHelper, in addition to the Kendo namespaces above, also add the following directive to the View:

Razor
    @addTagHelper *, Kendo.Mvc

Basic Configuration

You can declare the DataSource component configuration options by using the available methods—for example, you can define the page size, page, sort order, filter, group, aggregates, and the model.

The configuration accepts the definition for all CRUD operations and facilitates the data sorting, filtering, and grouping.

Razor
    @(Html.Kendo().DataSource<Kendo.Mvc.Examples.Models.ProductViewModel>()
        .Name("dataSource1")
        .Ajax(dataSource => dataSource
          .Read(read => read.Action("Products_Read", "DataSource"))
          .ServerOperation(false)
          .PageSize(5)
          .Sort(sort => sort.Add("FieldName").Ascending())
          .Filter(filter => filter.Add(field => field.FieldName).StartsWith("A"))
          .Group(group => group.Add(field => field.FieldName))
        )
    )

Prevent Ajax Response Caching

To prevent Ajax response caching, refer to this section from the Frequently Asked Questions article

Model Mapping

In some cases, you may use view model objects instead of entities returned by Entity Framework. For example, you may want to avoid serializing all Entity Framework properties as JSON or prevent serialization exceptions caused by circular references.

To map to a ViewModel on the fly, pass a mapping lambda as a second parameter to the ToDataSourceResult() extension method.

The naming of the model properties of the view model objects and entities returned by Entity Framework must match. If usage of different naming is desired, implement model mapping.

C#
    public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
    {
        using (var northwind = new NorthwindEntities())
        {
            IQueryable<Product> products = northwind.Products;
            // Convert the Product entities to ProductViewModel instances.
            DataSourceResult result = products.ToDataSourceResult(request, product => new ProductViewModel
            {
                ProductID = product.ProductID,
                ProductName = product.ProductName,
                UnitsInStock = product.UnitsInStock
            });

            return Json(result);
        }
    }

Functionality and Features

FeatureDescription
ModelMany scenarios require you to configure the Model of the DataSource.
AggregatesYou can easily calculate the aggregates of the data set like Min, Max, Average, etc.
FilteringThe built-in filtering enables you to search for a subset of data among the items.
SortingThe DataSource supports ascending and descending sorting.
GroupingYou can group the returned data based on a common criteria.
HeadersYou can set request headers by using the Headers configuration option of the DataSource.
DataSource TypesYou can choose the type of DataSource that best fits your needs.
CRUD OperationsThe DataSource supports easy set up of its CRUD operations and handles the server response on its own.

Next Steps

See Also