-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjust DetectChanges events so they can be used to get a notification…
… when all changes for an entity have been detected (#28356)
- Loading branch information
1 parent
727b699
commit b121ee3
Showing
13 changed files
with
657 additions
and
283 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,14 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; | ||
|
||
namespace Microsoft.EntityFrameworkCore.ChangeTracking; | ||
|
||
/// <summary> | ||
/// Event arguments for the <see cref="ChangeTracker.DetectingChanges" /> event. | ||
/// Event arguments for the <see cref="ChangeTracker.DetectingAllChanges" /> event. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-state-changes">State changes of entities in EF Core</see> for more information and examples. | ||
/// </remarks> | ||
public class DetectChangesEventArgs : EventArgs | ||
{ | ||
private readonly InternalEntityEntry? _internalEntityEntry; | ||
private EntityEntry? _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> | ||
[EntityFrameworkInternal] | ||
public DetectChangesEventArgs(InternalEntityEntry? internalEntityEntry) | ||
{ | ||
_internalEntityEntry = internalEntityEntry; | ||
} | ||
|
||
/// <summary> | ||
/// If detecting changes for a single entity, then this is the <see cref="EntityEntry" /> for that entity. | ||
/// If detecting changes for an entire graph, then <see langword="null" />. | ||
/// </summary> | ||
public virtual EntityEntry? Entry | ||
=> _internalEntityEntry == null | ||
? null | ||
: (_entry ??= new EntityEntry(_internalEntityEntry)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; | ||
|
||
namespace Microsoft.EntityFrameworkCore.ChangeTracking; | ||
|
||
/// <summary> | ||
/// Event arguments for the <see cref="ChangeTracker.DetectingEntityChanges" /> event. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-state-changes">State changes of entities in EF Core</see> for more information and examples. | ||
/// </remarks> | ||
public class DetectEntityChangesEventArgs : DetectChangesEventArgs | ||
{ | ||
private readonly InternalEntityEntry _internalEntityEntry; | ||
private EntityEntry? _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> | ||
[EntityFrameworkInternal] | ||
public DetectEntityChangesEventArgs(InternalEntityEntry internalEntityEntry) | ||
{ | ||
_internalEntityEntry = internalEntityEntry; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="EntityEntry" /> for the entity. | ||
/// </summary> | ||
public virtual EntityEntry Entry | ||
=> _entry ??= new EntityEntry(_internalEntityEntry); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/EFCore/ChangeTracking/DetectedEntityChangesEventArgs.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using Microsoft.EntityFrameworkCore.ChangeTracking.Internal; | ||
|
||
namespace Microsoft.EntityFrameworkCore.ChangeTracking; | ||
|
||
/// <summary> | ||
/// Event arguments for the <see cref="ChangeTracker.DetectedEntityChanges" /> event. | ||
/// </summary> | ||
/// <remarks> | ||
/// See <see href="https://aka.ms/efcore-docs-state-changes">State changes of entities in EF Core</see> for more information and examples. | ||
/// </remarks> | ||
public class DetectedEntityChangesEventArgs : DetectedChangesEventArgs | ||
{ | ||
private readonly InternalEntityEntry _internalEntityEntry; | ||
private EntityEntry? _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> | ||
[EntityFrameworkInternal] | ||
public DetectedEntityChangesEventArgs( | ||
InternalEntityEntry internalEntityEntry, | ||
bool changesFound) | ||
: base(changesFound) | ||
{ | ||
_internalEntityEntry = internalEntityEntry; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="EntityEntry" /> for the entity. | ||
/// </summary> | ||
public virtual EntityEntry Entry | ||
=> _entry ??= new EntityEntry(_internalEntityEntry); | ||
} |
Oops, something went wrong.