-
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.
- Tracking - StateChanging - DetectingChanges - DetectedChanges Part of #626 Fixes #27093 Fixes #16256
- Loading branch information
1 parent
781ca24
commit 2f2950f
Showing
15 changed files
with
1,191 additions
and
203 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 |
---|---|---|
@@ -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.DetectingChanges" /> 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,35 @@ | ||
// 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.DetectedChanges" /> 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 DetectedChangesEventArgs : DetectChangesEventArgs | ||
{ | ||
/// <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 DetectedChangesEventArgs( | ||
InternalEntityEntry? internalEntityEntry, | ||
bool changesFound) | ||
: base(internalEntityEntry) | ||
{ | ||
ChangesFound = changesFound; | ||
} | ||
|
||
/// <summary> | ||
/// Returns <see langword="true" /> if changes were found, <see langword="false" /> otherwise. | ||
/// </summary> | ||
public virtual bool ChangesFound { get; } | ||
} |
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,42 @@ | ||
// 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.StateChanging" /> 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 EntityStateChangingEventArgs : EntityEntryEventArgs | ||
{ | ||
/// <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 EntityStateChangingEventArgs( | ||
InternalEntityEntry internalEntityEntry, | ||
EntityState oldState, | ||
EntityState newState) | ||
: base(internalEntityEntry) | ||
{ | ||
OldState = oldState; | ||
NewState = newState; | ||
} | ||
|
||
/// <summary> | ||
/// The state that the entity is transitioning from. | ||
/// </summary> | ||
public virtual EntityState OldState { get; } | ||
|
||
/// <summary> | ||
/// The state that the entity is transitioning to. | ||
/// </summary> | ||
public virtual EntityState NewState { get; } | ||
} |
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,42 @@ | ||
// 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.Tracking" /> 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 EntityTrackingEventArgs : EntityEntryEventArgs | ||
{ | ||
/// <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 EntityTrackingEventArgs( | ||
InternalEntityEntry internalEntityEntry, | ||
EntityState state, | ||
bool fromQuery) | ||
: base(internalEntityEntry) | ||
{ | ||
State = state; | ||
FromQuery = fromQuery; | ||
} | ||
|
||
/// <summary> | ||
/// The <see cref="EntityState" /> that the tracked entity will be tracked with. | ||
/// </summary> | ||
public virtual EntityState State { get; } | ||
|
||
/// <summary> | ||
/// <see langword="true" /> if the entity is being tracked as part of a database query; <see langword="false" /> otherwise. | ||
/// </summary> | ||
public virtual bool FromQuery { get; } | ||
} |
Oops, something went wrong.