-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add complex collection support to PropertyValues #36366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the PropertyValues
infrastructure in EF Core to fully support complex collection properties. It adds new APIs and internal logic to:
- Store, clone, and materialize complex collections in
PropertyValues
,EntryPropertyValues
, andArrayPropertyValues
. - Detect, reorder, and track state changes in complex collection entries via
InternalEntryBase
andChangeDetector
. - Provide empty and populated materializers for complex types in
EntityMaterializerSource
. - Surface a clear error when complex type collections are used with the Cosmos provider.
Reviewed Changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/EFCore/ChangeTracking/PropertyValues.cs | Added IComplexProperty indexer, ComplexCollectionProperties , and abstracted SetValues to support complex collections. |
src/EFCore/ChangeTracking/Internal/InternalEntryBase.cs | Extended original/current value logic to reorder and detect complex collection entries on state changes. |
src/EFCore/ChangeTracking/Internal/ChangeDetector.cs | Enhanced DetectComplexCollectionChanges to handle additions, removals, moves, and null elements in complex collections. |
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs | Added storage for nested ArrayPropertyValues lists and logic to populate complex objects in ToObject() . |
src/EFCore/Query/Internal/EntityMaterializerSource.cs | Initialize complex collections to null during materialization and added public methods to get materializers for complex types. |
src/EFCore.Cosmos/Infrastructure/Internal/CosmosModelValidator.cs | Throw an exception for unsupported complex type collections in the Cosmos provider. |
Files not reviewed (2)
- src/EFCore.Cosmos/Properties/CosmosStrings.Designer.cs: Language not supported
- src/EFCore/Properties/CoreStrings.Designer.cs: Language not supported
Comments suppressed due to low confidence (1)
src/EFCore/Query/IEntityMaterializerSource.cs:83
- [nitpick] The XML documentation for GetMaterializer and GetEmptyMaterializer still refers to "entity type" and mentions caching, but these methods now target complex types and always compile a new delegate. Update the
<summary>
and<param>
tags to correctly describe complex type materialization and clarify that the returned delegate is not necessarily cached.
/// <para>
827202c
to
351ae49
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐑 🇮🇹 on some parts of change detection, but overall understandable and LGTM.
bfa6a86
to
af9e1dc
Compare
af9e1dc
to
1b05bed
Compare
Part of #31237
This pull request extends
PropertyValues
and derived types to handle complex collection properties and adds an error message in the Cosmos provider strings. It also fixes some bugs in complex collection change detection.Enhancements to
PropertyValues
:PropertyValues.cs
: Extended the class to support complex collection properties, including methods for cloning, setting values, and converting complex collections to objects. Introduced new properties likeComplexCollectionProperties
for managing complex type collections.Validation for complex type collections:
CosmosModelValidator.cs
: Throw for complex type collections on Cosmos.