Skip to content

Commit

Permalink
Fixup navigations to/from join entity when new many-to-many relations…
Browse files Browse the repository at this point in the history
…hip is created

Fixes #26779

Also cleanup of delay-fixup/suspended detection logic, and tests for #26074.
  • Loading branch information
ajcvickers committed Dec 5, 2021
1 parent fe1f86d commit fabea3f
Show file tree
Hide file tree
Showing 11 changed files with 1,612 additions and 141 deletions.
25 changes: 2 additions & 23 deletions src/EFCore/ChangeTracking/Internal/ChangeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class ChangeDetector : IChangeDetector
{
private readonly IDiagnosticsLogger<DbLoggerCategory.ChangeTracking> _logger;
private readonly ILoggingOptions _loggingOptions;
private bool _suspended;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand All @@ -33,24 +32,6 @@ public ChangeDetector(
_loggingOptions = loggingOptions;
}

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Suspend()
=> _suspended = true;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
public virtual void Resume()
=> _suspended = false;

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
Expand All @@ -59,8 +40,7 @@ public virtual void Resume()
/// </summary>
public virtual void PropertyChanged(InternalEntityEntry entry, IPropertyBase propertyBase, bool setModified)
{
if (_suspended
|| entry.EntityState == EntityState.Detached
if (entry.EntityState == EntityState.Detached
|| propertyBase is IServiceProperty)
{
return;
Expand Down Expand Up @@ -103,8 +83,7 @@ private static void ThrowIfKeyChanged(InternalEntityEntry entry, IProperty prope
/// </summary>
public virtual void PropertyChanging(InternalEntityEntry entry, IPropertyBase propertyBase)
{
if (_suspended
|| entry.EntityState == EntityState.Detached
if (entry.EntityState == EntityState.Detached
|| propertyBase is IServiceProperty)
{
return;
Expand Down
16 changes: 0 additions & 16 deletions src/EFCore/ChangeTracking/Internal/IChangeDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,4 @@ public interface IChangeDetector
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void DetectChanges(InternalEntityEntry entry);

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void Suspend();

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void Resume();
}
6 changes: 3 additions & 3 deletions src/EFCore/ChangeTracking/Internal/INavigationFixer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,23 @@ public interface INavigationFixer
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void BeginAttachGraph();
bool BeginDelayedFixup();

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void CompleteAttachGraph();
void CompleteDelayedFixup();

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
/// any release. You should only use it directly in your code with extreme caution and knowing that
/// doing so can result in application failures when updating to a new Entity Framework Core release.
/// </summary>
void AbortAttachGraph();
void AbortDelayedFixup();

/// <summary>
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
Expand Down
Loading

0 comments on commit fabea3f

Please sign in to comment.