Last Updated:
22 Oct 2026 06:15
by ADMIN
2026.3.1015 regression: ToDataSourceResult default sort picks [NotMapped] properties and replaces the query's OrderBy (EF Core)
Description:
After upgrading Telerik.UI.for.AspNet.Core from 2026.3.811 to 2026.3.1015, ToDataSourceResult and
ToDataSourceResultAsync behave differently over Entity Framework Core queries when the
DataSourceRequest contains no sorts. That is the request a DropDownList or Grid sends when no sort is
configured ("sort=&group=&filter="). This change is not in the 2026.3.1015 release notes.
In 2026.3.1015 the method appends OrderBy(<first primitive property of the element type, in
declaration order>). In 2026.3.811 it adds no sort, and the query's own ordering is kept. This causes
two problems.
ISSUE 1: The default sort can pick a property EF Core cannot translate.
The chosen property is not checked against the EF model. If the first declared property is
[NotMapped], or is get-only with no backing column, the query fails:
System.InvalidOperationException: The LINQ expression 'DbSet<Customer>()
.OrderBy(c => c.Name)
.OrderBy(c => c.Id)' could not be translated. Additional information: Translation of member
'Id' on entity type 'Customer' failed. This commonly occurs when the specified member is unmapped.
This is a common pattern: a convenience "Id" property that maps to the real key (for example
"[NotMapped] public int Id => CustomerId;"). In our application, every dropdown read over an entity
shaped like this returns HTTP 500 after the upgrade.
ISSUE 2: The default sort replaces the caller's ordering.
The default sort is applied as OrderBy, not ThenBy. An ordering the caller already applied to the
IQueryable is thrown away. db.Products.OrderBy(p => p.Name).ToDataSourceResultAsync(request) now
returns rows in primary-key order (SQL: ORDER BY "ProductId"), not by Name. Applying an OrderBy
before calling ToDataSourceResult therefore no longer controls the order, so it is not a workaround.
ENVIRONMENT
- .NET 10, ASP.NET Core 10
- Microsoft.EntityFrameworkCore 10.0.12 (reproduced with SQL Server and with SQLite)
- Telerik.UI.for.AspNet.Core 2026.3.811 (works) vs 2026.3.1015 (fails)
STEPS TO REPRODUCE
The attached TelerikNotMappedSortRepro.zip is a self-contained console app: EF Core with an in-memory
SQLite database, no server, three files.
1. dotnet run
(uses 2026.3.1015)
2. Delete obj/ and bin/, then: dotnet run -p:KendoVersion=2026.3.811
ACTUAL (2026.3.1015)
- Issue 1: InvalidOperationException, shown above
- Issue 2: Banana, Cherry, Apple (ORDER BY "ProductId")
EXPECTED (and the result with 2026.3.811)
- Issue 1: Apple, Banana, Cherry (ORDER BY "Name")
- Issue 2: Apple, Banana, Cherry (ORDER BY "Name")
SUGGESTED FIX
- When choosing a default sort column for an EF query, use only properties EF maps (for example, the
entity's primary key from the EF model), never [NotMapped] or get-only co
- Do not replace an ordering already on the query. Use ThenBy, or skip the default sort when the
expression already contains an OrderBy.
QUESTIONS
1. What changed between 2026.3.811 and 2026.3.1015 that makes this default sort apply to EF Core
queries now?
2. Is there a supported way to turn the default sort off, or to choose its
explicit Sort to every DataSource on the client? We have many endpoints
ordering.
3. Is a fix planned, and in which release?