dotnet / dotnet/efcore

Support ExecuteUpdate with subquery when a complex type is projected

Open
#36,336 1 comment 2 reactions 0 assignees View on GitHub
area-bulkupdate area-complex-types
Dominant language
C#
Stars
14.8k
Forks
3.4k
PR merge metrics
PR metrics pending

Description

For ExecuteUpdate, whenever we encounter a SQL operation that isn't natively supported by the database's UPDATE statement, we transform into a PK subquery. When that happens, we need the primary key properties of the projected entity type in order to correctly generate the subquery.

In that code path, we have a check that the projected type is an entity type:

```c#
if (shaper.StructuralType is not IEntityType entityType)
{
AddTranslationErrorDetails(
RelationalStrings.ExecuteUpdateSubqueryNotSupportedOverComplexTypes(shaper.StructuralType.DisplayName()));
return null;
}
```

This blocks cases where a complex type is being projected, although it should be possible to get the containing entity type and create the query from that.

Originally raised by @PatTheHyruler in https://github.com/npgsql/efcore.pg/issues/3573#issuecomment-3046753649 (thanks).

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.