You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add View, TVF and SqlQuery mapping support for complex types #34627
Hello @AndriySvyryd , am looking forward to work on this issue.
I looked at CreateViewMapping , and it seems that we are not adding runtime mappings for complex types (we do at CreateTableMapping)
Is adding the foreach loop just like createtablemapping is enough to fix this ?
something like this commit: 0d1f0c1
we also have to change some type params from IEntityType to ITypeBase; just like table mappings
this test does fail , but it test that the select expression throw exception, which shouldn't be the case; as we should query complex type with no issues
the issue is with the update logic using select expression translation first then trying to update
it still fails with an exception but different one sql command exception as it's trying to update the view not the table
Generally, on the right track, but GetViewOrTableMappings should still only return one set of mappings
I didn't change this part. it still return one mapping
The bulk update logic should be changed to only consider table mappings
does this have to be in the same pr ?
this change is more complex than just adding metadata for this issue.
I can add a boolean forUpdate (deafult: false) to indicate if the sql translator is for update or read
for example _sqlTranslator.TryBindMember will pass the new parameter to be true, and pass it down to structuralTypeProjection.BindComplexProperty
to pass it down to SelectExpression.GenerateComplexPropertyShaperExpression
then we can only return the table mapping inside
but that leaves us with an issue that the StructuralTypeProjectionExpression containerProjection is still referencing the view not the table , so it will still fail with the old exception (in case of table+view mappings). is that okay ?
Understood. FWIW I'm doing some pretty heavy refactoring to support TPC (#35025), and the hack currently in place to support SqlQuery won't be easy to carry forward. So we'll soon need proper support for it.
Activity
kirolous-nashaat commentedon Sep 27, 2025
Hello @AndriySvyryd , am looking forward to work on this issue.
I looked at CreateViewMapping , and it seems that we are not adding runtime mappings for complex types (we do at CreateTableMapping)
Is adding the foreach loop just like createtablemapping is enough to fix this ?
something like this commit: 0d1f0c1
we also have to change some type params from IEntityType to ITypeBase; just like table mappings
the only concern i have after further thoughts:
efcore/test/EFCore.Relational.Specification.Tests/BulkUpdates/NonSharedModelBulkUpdatesRelationalTestBase.cs
Line 112 in 6dcffd0
this test does fail , but it test that the select expression throw exception, which shouldn't be the case; as we should query complex type with no issues
the issue is with the update logic using select expression translation first then trying to update
it still fails with an exception but different one sql command exception as it's trying to update the view not the table
kirolous-nashaat commentedon Sep 28, 2025
looping @roji as he worked on that test above
AndriySvyryd commentedon Oct 10, 2025
Generally, on the right track, but
GetViewOrTableMappingsshould still only return one set of mappingsThe bulk update logic should be changed to only consider table mappings
kirolous-nashaat commentedon Oct 12, 2025
I didn't change this part. it still return one mapping
does this have to be in the same pr ?
this change is more complex than just adding metadata for this issue.
I can add a boolean forUpdate (deafult: false) to indicate if the sql translator is for update or read
for example
_sqlTranslator.TryBindMemberwill pass the new parameter to be true, and pass it down tostructuralTypeProjection.BindComplexPropertyto pass it down to
SelectExpression.GenerateComplexPropertyShaperExpressionthen we can only return the table mapping inside
but that leaves us with an issue that the
StructuralTypeProjectionExpression containerProjectionis still referencing the view not the table , so it will still fail with the old exception (in case of table+view mappings). is that okay ?4 remaining items
Added metadata support for complex types mapped to views (#37072)
Work around the lack of complex types in default relational mappings
Work around the lack of complex types in default relational mappings (#…
roji commentedon Dec 14, 2025
@AndriySvyryd is this fixed by #37072, or are we still missing metadata support for complex types?
AndriySvyryd commentedon Dec 15, 2025
TVF and SqlQuery support is still missing
roji commentedon Dec 16, 2025
Understood. FWIW I'm doing some pretty heavy refactoring to support TPC (#35025), and the hack currently in place to support SqlQuery won't be easy to carry forward. So we'll soon need proper support for it.
Complexproperty does not work with raw SQL #38461 as a duplicate of this issue第8章:データベースアクセスと ORM(Entity Framework Core)を追加 (#54)