@@ -38,7 +38,7 @@ public ChangeDetector(
3838 /// any release. You should only use it directly in your code with extreme caution and knowing that
3939 /// doing so can result in application failures when updating to a new Entity Framework Core release.
4040 /// </summary>
41- public virtual void PropertyChanged ( InternalEntityEntry entry , IPropertyBase propertyBase , bool setModified )
41+ public virtual void PropertyChanged ( IInternalEntry entry , IPropertyBase propertyBase , bool setModified )
4242 {
4343 if ( entry . EntityState == EntityState . Detached
4444 || propertyBase is IServiceProperty )
@@ -62,16 +62,16 @@ public virtual void PropertyChanged(InternalEntityEntry entry, IPropertyBase pro
6262 else if ( propertyBase . GetRelationshipIndex ( ) != - 1
6363 && propertyBase is INavigationBase navigation )
6464 {
65- DetectNavigationChange ( entry , navigation ) ;
65+ DetectNavigationChange ( ( InternalEntityEntry ) entry , navigation ) ;
6666 }
6767 }
6868
69- private static void ThrowIfKeyChanged ( InternalEntityEntry entry , IProperty property )
69+ private static void ThrowIfKeyChanged ( IInternalEntry entry , IProperty property )
7070 {
7171 if ( property . IsKey ( )
7272 && property . GetAfterSaveBehavior ( ) == PropertySaveBehavior . Throw )
7373 {
74- throw new InvalidOperationException ( CoreStrings . KeyReadOnly ( property . Name , entry . EntityType . DisplayName ( ) ) ) ;
74+ throw new InvalidOperationException ( CoreStrings . KeyReadOnly ( property . Name , entry . StructuralType . DisplayName ( ) ) ) ;
7575 }
7676 }
7777
@@ -81,15 +81,15 @@ private static void ThrowIfKeyChanged(InternalEntityEntry entry, IProperty prope
8181 /// any release. You should only use it directly in your code with extreme caution and knowing that
8282 /// doing so can result in application failures when updating to a new Entity Framework Core release.
8383 /// </summary>
84- public virtual void PropertyChanging ( InternalEntityEntry entry , IPropertyBase propertyBase )
84+ public virtual void PropertyChanging ( IInternalEntry entry , IPropertyBase propertyBase )
8585 {
8686 if ( entry . EntityState == EntityState . Detached
8787 || propertyBase is IServiceProperty )
8888 {
8989 return ;
9090 }
9191
92- if ( ! entry . EntityType . UseEagerSnapshots ( ) )
92+ if ( ! entry . StructuralType . UseEagerSnapshots ( ) )
9393 {
9494 if ( propertyBase is IProperty asProperty
9595 && asProperty . GetOriginalValueIndex ( ) != - 1 )
@@ -99,7 +99,7 @@ public virtual void PropertyChanging(InternalEntityEntry entry, IPropertyBase pr
9999
100100 if ( propertyBase . GetRelationshipIndex ( ) != - 1 )
101101 {
102- entry . EnsureRelationshipSnapshot ( ) ;
102+ ( ( InternalEntityEntry ) entry ) . EnsureRelationshipSnapshot ( ) ;
103103 }
104104 }
105105 }
@@ -274,7 +274,7 @@ private bool LocalDetectChanges(InternalEntityEntry entry)
274274 /// any release. You should only use it directly in your code with extreme caution and knowing that
275275 /// doing so can result in application failures when updating to a new Entity Framework Core release.
276276 /// </summary>
277- public bool DetectValueChange ( InternalEntityEntry entry , IProperty property )
277+ public bool DetectValueChange ( IInternalEntry entry , IProperty property )
278278 {
279279 var current = entry [ property ] ;
280280 var original = entry . GetOriginalValue ( property ) ;
@@ -296,26 +296,33 @@ public bool DetectValueChange(InternalEntityEntry entry, IProperty property)
296296 return false ;
297297 }
298298
299- private void LogChangeDetected ( InternalEntityEntry entry , IProperty property , object ? original , object ? current )
299+ private void LogChangeDetected ( IInternalEntry entry , IProperty property , object ? original , object ? current )
300300 {
301301 if ( _loggingOptions . IsSensitiveDataLoggingEnabled )
302302 {
303- _logger . PropertyChangeDetectedSensitive ( entry , property , original , current ) ;
303+ if ( entry is InternalEntityEntry entityEntry )
304+ {
305+ _logger . PropertyChangeDetectedSensitive ( entityEntry , property , original , current ) ;
306+ }
304307 }
305308 else
306309 {
307- _logger . PropertyChangeDetected ( entry , property , original , current ) ;
310+ if ( entry is InternalEntityEntry entityEntry )
311+ {
312+ _logger . PropertyChangeDetected ( entityEntry , property , original , current ) ;
313+ }
308314 }
309315 }
310316
311- private bool DetectKeyChange ( InternalEntityEntry entry , IProperty property )
317+ private bool DetectKeyChange ( IInternalEntry entry , IProperty property )
312318 {
313319 if ( property . GetRelationshipIndex ( ) < 0 )
314320 {
315321 return false ;
316322 }
317323
318- var snapshotValue = entry . GetRelationshipSnapshotValue ( property ) ;
324+ var entityEntry = ( InternalEntityEntry ) entry ;
325+ var snapshotValue = entityEntry . GetRelationshipSnapshotValue ( property ) ;
319326 var currentValue = entry [ property ] ;
320327
321328 var comparer = property . GetKeyValueComparer ( ) ;
@@ -326,19 +333,19 @@ private bool DetectKeyChange(InternalEntityEntry entry, IProperty property)
326333 {
327334 var keys = property . GetContainingKeys ( ) ;
328335 var foreignKeys = property . GetContainingForeignKeys ( )
329- . Where ( fk => fk . DeclaringEntityType . IsAssignableFrom ( entry . EntityType ) ) ;
336+ . Where ( fk => fk . DeclaringEntityType . IsAssignableFrom ( entityEntry . EntityType ) ) ;
330337
331338 if ( _loggingOptions . IsSensitiveDataLoggingEnabled )
332339 {
333- _logger . ForeignKeyChangeDetectedSensitive ( entry , property , snapshotValue , currentValue ) ;
340+ _logger . ForeignKeyChangeDetectedSensitive ( entityEntry , property , snapshotValue , currentValue ) ;
334341 }
335342 else
336343 {
337- _logger . ForeignKeyChangeDetected ( entry , property , snapshotValue , currentValue ) ;
344+ _logger . ForeignKeyChangeDetected ( entityEntry , property , snapshotValue , currentValue ) ;
338345 }
339346
340- entry . StateManager . InternalEntityEntryNotifier . KeyPropertyChanged (
341- entry , property , keys , foreignKeys , snapshotValue , currentValue ) ;
347+ entityEntry . StateManager . InternalEntityEntryNotifier . KeyPropertyChanged (
348+ entityEntry , property , keys , foreignKeys , snapshotValue , currentValue ) ;
342349
343350 return true ;
344351 }
@@ -487,7 +494,6 @@ public virtual void SetEvents(
487494 public virtual void OnDetectingEntityChanges ( InternalEntityEntry internalEntityEntry )
488495 {
489496 var @event = DetectingEntityChanges ;
490-
491497 if ( @event != null )
492498 {
493499 var changeTracker = internalEntityEntry . StateManager . Context . ChangeTracker ;
0 commit comments