8000 Refactor InternalEntityEntry in preparation for complex collection support by AndriySvyryd · Pull Request #36165 · dotnet/efcore · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Refactor InternalEntityEntry in preparation for complex collection support #36165

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

Merged
merged 1 commit into from
Jun 16, 2025

Conversation

AndriySvyryd
Copy link
Member
@AndriySvyryd AndriySvyryd commented May 30, 2025

Extract InternalEntryBase
Remove IInternalEntry.Object
Move common change-tracking code to TypeBase
Fix some minor model building issues related to complex types

Part of #31237

@AndriySvyryd AndriySvyryd requested a review from Copilot May 30, 2025 19:18
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner May 30, 2025 19:18
Copy link
@Copilot Copilot AI left a 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 refactors the internal change-tracking infrastructure to prepare for complex collection support by extracting InternalEntryBase, removing IInternalEntry.Object, and moving common change-tracking code to TypeBase.

  • Updates method signatures and parameter types to use IInternalEntry for better abstraction.
  • Introduces new state management via InternalEntryBase.StateData and adjusts snapshot and relationship handling.
  • Adjusts EF Core scaffolding and collection entry code to support complex types and collections.

Reviewed Changes

Copilot reviewed 208 out of 208 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/EFCore/ChangeTracking/Internal/ShadowValuesFactoryFactory.cs Adjusts GetPropertyCount signature and uses new indexer syntax for shadow values.
src/EFCore/ChangeTracking/Internal/RelationshipSnapshotFactoryFactory.cs Changes GetPropertyCount signature and safely casts structuralType where necessary.
src/EFCore/ChangeTracking/Internal/OriginalValuesFactoryFactory.cs Updates GetPropertyCount to use structuralType.Counts.OriginalValueCount.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.StateData.cs New file adding bit-level state management and property flag handling.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.SidecarValues.cs Updates signature by renaming to InternalEntryBase.
src/EFCore/ChangeTracking/Internal/InternalEntryBase.OriginalValues.cs Updates parameter types to use InternalEntryBase and revised OriginalValues factory.
src/EFCore/ChangeTracking/Internal/InternalEntityEntryNotifier.cs Changes method signatures to use IInternalEntry.
src/EFCore/ChangeTracking/Internal/IInternalEntry.cs Removes IInternalEntry.Object and adds properties/methods to support the new design.
src/EFCore/ChangeTracking/Internal/IChangeDetector.cs Updates change notification methods to use IInternalEntry.
src/EFCore/ChangeTracking/Internal/EmptyShadowValuesFactoryFactory.cs Signature updates for GetPropertyCount consistent with new types.
src/EFCore/ChangeTracking/Internal/ChangeDetector.cs Updates change detection logic and method signatures to use IInternalEntry with necessary casts.
src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs Uses new collection expression syntax for initializing properties.
src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs Updates constructor parameter from InternalEntityEntry to IInternalEntry and property access.
src/EFCore/ChangeTracking/ComplexPropertyEntry.cs Similar constructor and IsModified changes for complex properties.
src/EFCore/ChangeTracking/CollectionEntry`.cs Adjusts property access and collection query logic to use InternalEntityEntry consistently.
src/EFCore/ChangeTracking/CollectionEntry.cs Updates collection entry code to work with the refactored change-tracking types.
src/EFCore.Design/Scaffolding/Internal/CSharpRuntimeModelCodeGenerator.cs Introduces support for complex collections and updates generated counts accordingly.
Comments suppressed due to low confidence (3)

src/EFCore/ChangeTracking/ComplexPropertyEntry`.cs:34

  • The file name contains an unexpected backtick (`). Consider renaming the file to remove the backtick for consistency.
public ComplexPropertyEntry(IInternalEntry internalEntry, IComplexProperty complexProperty)

src/EFCore/ChangeTracking/CollectionEntry`.cs:62

  • The file name includes an extraneous backtick (`); consider renaming the file to remove it for consistency with project naming conventions.
=> new(InternalEntityEntry);

src/EFCore/ChangeTracking/Internal/ArrayPropertyValues.cs:111

  • The use of the collection expression syntax initializes _properties as an array rather than a List as before. Verify that downstream code expecting a List is updated or that the array behavior is acceptable.
=> _properties ??= [.. EntityType.GetFlattenedProperties()];

@AndriySvyryd AndriySvyryd force-pushed the Issue31237_Refactor branch 5 times, most recently from 24e1985 to 61659f2 Compare June 4, 2025 21:32
@AndriySvyryd AndriySvyryd force-pushed the Issue31237_Refactor branch 5 times, most recently from 0d8b2df to b7234f9 Compare June 11, 2025 23:27
Copy link
Member
@roji roji left a comment
8000

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🐑 🇮🇹 looks legit :)

@@ -1219,7 +1324,7 @@ public virtual ChangeTrackingStrategy GetChangeTrackingStrategy()
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public static string? CheckChangeTrackingStrategy(
IReadOnlyTypeBase typeBase,
IReadOnlyTypeBase structuralType,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this in the past, but should we consider renaming ITypeBase IStructuralType? While technically a breaking change, it's very unlikely anyone actually uses this... We could still keep ITypeBase as an obsolete super-interface of IStructuralType to get people some time etc.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's worth it yet. Will reconsider when we have another thing that implements it

@AndriySvyryd AndriySvyryd force-pushed the Issue31237_Refactor branch 3 times, most recently from e826135 to 579bb61 Compare June 13, 2025 23:20
@AndriySvyryd AndriySvyryd enabled auto-merge (squash) June 13, 2025 23:27
@AndriySvyryd AndriySvyryd force-pushed the Issue31237_Refactor branch from 579bb61 to 24e3747 Compare June 16, 2025 00:09
@AndriySvyryd AndriySvyryd merged commit d994045 into main Jun 16, 2025
7 checks passed
@AndriySvyryd AndriySvyryd deleted the Issue31237_Refactor branch June 16, 2025 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0