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

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.