dotnet / dotnet/efcore

Consider not transforming member access to EF.Property in query pipeline

Open
#36,785 0 comments 0 reactions 0 assignees View on GitHub
area-query
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

We have EF.Property() as a user-facing mechanism for referencing shadow properties, which don't have a .NET property associated with them. At some point, we started also transforming regular MemberExpressions - where a .NET property **does** exist - into EF.Property nodes, as a sort of "universal representation" of property access within the query pipeline.

* EF.Property isn't client-evaluatable, so if a transformed EF.Property node ends up in client-evaluated code, the query fails. This is what happened in [#36761](https://github.com/dotnet/efcore/issues/36761).
* EF.Property obfuscates the expression trees we show to users in exception messages. That is, the user wrote simple .NET code with property access, but they're presented with an odd EF.Property MethodCallExpression node instead.
* EF.Property isn't universally used: in some cases we transform, in others we don't. So the value here is limited.
* Such transformations are inherently problematic with NativeAOT/trimming, since we need to do MakeGenericType to create the node (though this problem exists in many other areas).

Contributor guide

Open the contributing guide

Research direction

Start by tracing the query pipeline transformations that convert regular MemberExpressions into EF.Property nodes. Compare those paths with user-facing shadow-property access, client evaluation, exception expression output, and the MakeGenericType concern. Done requires a decided transformation policy and validation that the reported failure modes are addressed.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
database
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.