.NET 10 Preview 1 includes new Entity Framework Core features & enhancements:
- Support for the .NET 10 LeftJoin operator
- ExecuteUpdateAsync now accepts a regular, non-expression lambda
- Several small improvements
Entity Framework Core 10 updates:
LEFT JOIN is a common and useful operation when working with EF Core. In previous versions, implementing LEFT JOIN in LINQ was quite complicated, requiring SelectMany, GroupJoin and DefaultIfEmpty operations in a particular configuration:
var query = students
.GroupJoin(
departments,
student => student.DepartmentID,
department => department.ID,
(student, departmentList) => new { student, subgroup = departmentList })
.SelectMany(
joinedSet => joinedSet.subgroup.DefaultIfEmpty(),
(student, department) => new
{
student.student.FirstName,
student.student.LastName,
Department = department?.Name ?? "[NONE]"
});.NET 10 adds first-class LINQ support for LeftJoin method to make those queries much simpler to write. EF Core recognizes the new method, so it can be used in EF LINQ queries instead of the old construct:
var query = students
.LeftJoin(
departments,
student => student.DepartmentID,
department => department.ID,
(student, departmentList) => new
{
student.student.FirstName,
student.student.LastName,
Department = department?.Name ?? "[NONE]"
});See #12793 for more details.
Creating expresion trees can be verbose, and now you can use regular, non-expression lambdas when calling ExecuteUpdateAsync:
await context.Blogs.ExecuteUpdateAsync(s =>
{
s.SetProperty(b => b.Views, 8);
if (nameChanged)
{
s.SetProperty(b => b.Name, "foo");
}
});Thanks to @aradalvand for proposing and pushing for this change (in #32018).
- Translation for DateOnly.ToDateTime(timeOnly) (#35194, contributed by @mseada94).
- Optimization for multiple consecutive
LIMITs (#35384, contributed by @ranma42). - Optimization for use of
Countoperation onICollection<T>(#35381, contributed by @ChrisJollyAU). - Optimization for
MIN/MAXoverDISTINCT(#34699, contributed by @ranma42). - Make SQL Server scaffolding compatible with Azure Data Explorer (#34832, contributed by @barnuri).
- Translation for date/time functions using
DatePart.MicrosecondandDatePart.Nanosecondarguments (#34861). - Simplifying parameter names (e.g. from
@__city_0tocity) (#35200).
Preview 1 contains: