@@ -46,20 +46,29 @@ public override async Task NullSafeSetAsync(DbCommand cmd, object value, int ind
46
46
. NullSafeSetAsync ( cmd , await ( GetReferenceValueAsync ( value , session , cancellationToken ) ) . ConfigureAwait ( false ) , index , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
47
47
}
48
48
49
- public override Task < bool > IsDirtyAsync ( object old , object current , ISessionImplementor session , CancellationToken cancellationToken )
49
+ public override async Task < bool > IsDirtyAsync ( object old , object current , ISessionImplementor session , CancellationToken cancellationToken )
50
50
{
51
- if ( cancellationToken . IsCancellationRequested )
51
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
52
+ if ( IsSame ( old , current ) )
52
53
{
53
- return Task . FromCanceled < bool > ( cancellationToken ) ;
54
+ return false ;
54
55
}
55
- try
56
+
57
+ if ( old == null || current == null )
56
58
{
57
- return Task . FromResult < bool > ( IsDirty ( old , current , session ) ) ;
59
+ return true ;
58
60
}
59
- catch ( Exception ex )
61
+
62
+ if ( ( await ( ForeignKeys . IsTransientFastAsync ( GetAssociatedEntityName ( ) , current , session , cancellationToken ) ) . ConfigureAwait ( false ) ) . GetValueOrDefault ( ) )
60
63
{
61
- return Task . FromException < bool > ( ex ) ;
64
+ return true ;
62
65
}
66
+
67
+ object oldId = await ( GetIdentifierAsync ( old , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
68
+ object newId = await ( GetIdentifierAsync ( current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
69
+ IType identifierType = GetIdentifierType ( session ) ;
70
+
71
+ return await ( identifierType . IsDirtyAsync ( oldId , newId , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
63
72
}
64
73
65
74
public override Task < bool > IsDirtyAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
@@ -68,14 +77,7 @@ public override Task<bool> IsDirtyAsync(object old, object current, bool[] check
68
77
{
69
78
return Task . FromCanceled < bool > ( cancellationToken ) ;
70
79
}
71
- try
72
- {
73
- return Task . FromResult < bool > ( IsDirty ( old , current , checkable , session ) ) ;
74
- }
75
- catch ( Exception ex )
76
- {
77
- return Task . FromException < bool > ( ex ) ;
78
- }
80
+ return this . IsDirtyAsync ( old , current , session , cancellationToken ) ;
79
81
}
80
82
81
83
public override Task < bool > IsModifiedAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
0 commit comments