dotnet / dotnet/efcore

Add extension methods to turn relational nulls on/of for an individual LINQ query

Open
#32,453 12 comments 0 reactions 0 assignees View on GitHub
area-query customer-reported
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

In EF6, using database null semantics could easily be switched on or off per context instance. In EF-core, using database semantics has become part of the model configuration (`UseRelationalNulls()`). If we want to turn this behavior on/off we have to add code to the context class, for instance adding a boolean in its constructor and calling `UseRelationalNulls(booleanMember)` in `OnConfiguring`. It's quite a hassle to do this esp. when using dependency injection.

I would prefer having extension methods `AsRelationalNulls` / `AsNoRelationalNulls` (in the line of `AsTracking`, `AsNoTracking`, `AsSplitQuery`, etc. in `EntityFrameworkQueryableExtensions`) that can be used to add this behavior to individual LINQ queries.

Just as `AsTracking`, `AsNoTracking`, it would depend on the initial context configuration which of the two methods is a no-op.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.