@@ -171,37 +171,25 @@ public static async Task<bool> IsNotTransientSlowAsync(string entityName, object
171
171
/// <remarks>
172
172
/// Don't hit the database to make the determination, instead return null;
173
173
/// </remarks>
174
- public static Task < bool ? > IsTransientFastAsync ( string entityName , object entity , ISessionImplementor session , CancellationToken cancellationToken )
174
+ public static async Task < bool ? > IsTransientFastAsync ( string entityName , object entity , ISessionImplementor session , CancellationToken cancellationToken )
175
175
{
176
- if ( cancellationToken . IsCancellationRequested )
176
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
177
+ if ( Equals ( Intercept . LazyPropertyInitializer . UnfetchedProperty , entity ) )
177
178
{
178
- return Task . FromCanceled < bool ? > ( cancellationToken ) ;
179
+ // an unfetched association can only point to
180
+ // an entity that already exists in the db
181
+ return false ;
179
182
}
180
- try
181
- {
182
- if ( Equals ( Intercept . LazyPropertyInitializer . UnfetchedProperty , entity ) )
183
- {
184
- // an unfetched association can only point to
185
- // an entity that already exists in the db
186
- return Task . FromResult < bool ? > ( false ) ;
187
- }
188
-
189
- // let the interceptor inspect the instance to decide
190
- if ( session . Interceptor . IsTransient ( entity ) == true )
191
- return Task . FromResult < bool ? > ( true ) ;
192
183
193
- if ( entity is INHibernateProxy proxy && proxy . HibernateLazyInitializer . IsUninitialized )
194
- {
195
- return Task . FromResult < bool ? > ( false ) ;
196
- }
197
-
198
- // let the persister inspect the instance to decide
199
- return session . GetEntityPersister ( entityName , entity ) . IsTransientAsync ( entity , session , cancellationToken ) ;
200
- }
201
- catch ( System . Exception ex )
184
+ if ( entity is INHibernateProxy proxy && proxy . HibernateLazyInitializer . IsUninitialized )
202
185
{
203
- return Task . FromException < bool ? > ( ex ) ;
186
+ return false ;
204
187
}
188
+
189
+ // let the interceptor inspect the instance to decide
190
+ // let the persister inspect the instance to decide
191
+ return session . Interceptor . IsTransient ( entity ) ??
192
+ await ( session . GetEntityPersister ( entityName , entity ) . IsTransientAsync ( entity , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
205
193
}
206
194
207
195
/// <summary>
0 commit comments