@@ -135,37 +135,49 @@ private Task<object> AssembleIdAsync(object oid, ISessionImplementor session, Ca
135
135
}
136
136
}
137
137
138
- public override async Task < bool > IsDirtyAsync ( object old , object current , ISessionImplementor session , CancellationToken cancellationToken )
138
+ public override Task < bool > IsDirtyAsync ( object old , object current , ISessionImplementor session , CancellationToken cancellationToken )
139
139
{
140
- cancellationToken . ThrowIfCancellationRequested ( ) ;
141
- if ( IsSame ( old , current ) )
140
+ if ( cancellationToken . IsCancellationRequested )
142
141
{
143
- return false ;
142
+ return Task . FromCanceled < bool > ( cancellationToken ) ;
144
143
}
144
+ return IsDirtyManyToOneAsync ( old , current , null , session , cancellationToken ) ;
145
+ }
145
146
146
- object oldid = await ( GetIdentifierAsync ( old , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
147
- object newid = await ( GetIdentifierAsync ( current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
148
- return await ( GetIdentifierType ( session ) . IsDirtyAsync ( oldid , newid , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
147
+ public override Task < bool > IsDirtyAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
148
+ {
149
+ if ( cancellationToken . IsCancellationRequested )
150
+ {
151
+ return Task . FromCanceled < bool > ( cancellationToken ) ;
152
+ }
153
+ return IsDirtyManyToOneAsync ( old , current , IsAlwaysDirtyChecked ? null : checkable , session , cancellationToken ) ;
149
154
}
150
155
151
- public override async Task < bool > IsDirtyAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
156
+ private async Task < bool > IsDirtyManyToOneAsync ( object old , object current , bool [ ] checkable , ISessionImplementor session , CancellationToken cancellationToken )
152
157
{
153
158
cancellationToken . ThrowIfCancellationRequested ( ) ;
154
- if ( IsAlwaysDirtyChecked )
159
+ if ( IsSame ( old , current ) )
160
+ {
161
+ return false ;
162
+ }
163
+
164
+ if ( old == null || current == null )
155
165
{
156
- return await ( IsDirtyAsync ( old , current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
166
+ return true ;
157
167
}
158
- else
168
+
169
+ if ( await ( ForeignKeys . IsTransientFastAsync ( GetAssociatedEntityName ( ) , current , session , cancellationToken ) ) . ConfigureAwait ( false ) == true )
159
170
{
160
- if ( IsSame ( old , current ) )
161
- {
162
- return false ;
163
- }
164
-
165
- object oldid = await ( GetIdentifierAsync ( old , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
166
- object newid = await ( GetIdentifierAsync ( current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
167
- return await ( GetIdentifierType ( session ) . IsDirtyAsync ( oldid , newid , checkable , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
171
+ return true ;
168
172
}
173
+
174
+ object oldid = await ( GetIdentifierAsync ( old , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
175
+ object newid = await ( GetIdentifierAsync ( current , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
176
+ IType identifierType = GetIdentifierType ( session ) ;
177
+
178
+ return checkable == null
179
+ ? await ( identifierType . IsDirtyAsync ( oldid , newid , session , cancellationToken ) ) . ConfigureAwait ( false )
180
+ : await ( identifierType . IsDirtyAsync ( old , current , checkable , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
169
181
}
170
182
}
171
183
}
0 commit comments