@@ -80,20 +80,21 @@ public override Task<bool> IsDirtyAsync(object old, object current, bool[] check
80
80
return this . IsDirtyAsync ( old , current , session , cancellationToken ) ;
81
81
}
82
82
83
- public override Task < bool > IsModifiedAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
83
+ public override async Task < bool > IsModifiedAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
84
84
{
85
- if ( cancellationToken . IsCancellationRequested )
86
- {
87
- return Task . FromCanceled < bool > ( cancellationToken ) ;
88
- }
89
- try
85
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
86
+ if ( current == null )
90
87
{
91
- return Task . FromResult < bool > ( IsModified ( old , current , checkable , session ) ) ;
88
+ return old != null ;
92
89
}
93
- catch ( Exception ex )
90
+ if ( old == null )
94
91
{
95
- return Task . FromException < bool > ( ex ) ;
92
+ return true ;
96
93
}
94
+ var oldIdentifier = IsIdentifier ( old , session ) ? old : await ( GetIdentifierAsync ( old , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
95
+ var currentIdentifier = await ( GetIdentifierAsync ( current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
96
+ // the ids are fully resolved, so compare them with isDirty(), not isModified()
97
+ return await ( GetIdentifierOrUniqueKeyType ( session . Factory ) . IsDirtyAsync ( oldIdentifier , currentIdentifier , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
97
98
}
98
99
99
100
public override async Task < object > HydrateAsync ( DbDataReader rs , string [ ] names , ISessionImplementor session , object owner , CancellationToken cancellationToken )
0 commit comments