@@ -157,10 +157,6 @@ private async Task<bool> IsNullifiableAsync(string entityName, object obj, Cance
157
157
public static async Task < bool > IsNotTransientSlowAsync ( string entityName , object entity , ISessionImplementor session , CancellationToken cancellationToken )
158
158
{
159
159
cancellationToken . ThrowIfCancellationRequested ( ) ;
160
- if ( entity . IsProxy ( ) )
161
- return true ;
162
- if ( session . PersistenceContext . IsEntryFor ( entity ) )
163
- return true ;
164
160
return ! await ( IsTransientSlowAsync ( entityName , entity , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
165
161
}
166
162
@@ -171,38 +167,25 @@ public static async Task<bool> IsNotTransientSlowAsync(string entityName, object
171
167
/// <remarks>
172
168
/// Don't hit the database to make the determination, instead return null;
173
169
/// </remarks>
174
- public static Task < bool ? > IsTransientFastAsync ( string entityName , object entity , ISessionImplementor session , CancellationToken cancellationToken )
170
+ public static async Task < bool ? > IsTransientFastAsync ( string entityName , object entity , ISessionImplementor session , CancellationToken cancellationToken )
175
171
{
176
- if ( cancellationToken . IsCancellationRequested )
172
+ cancellationToken . ThrowIfCancellationRequested ( ) ;
173
+ if ( Equals ( Intercept . LazyPropertyInitializer . UnfetchedProperty , entity ) )
177
174
{
178
- return Task . FromCanceled < bool ? > ( cancellationToken ) ;
175
+ // an unfetched association can only point to
176
+ // an entity that already exists in the db
177
+ return false ;
179
178
}
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
179
189
- // let the interceptor inspect the instance to decide
190
- var isTransient = session . Interceptor . IsTransient ( entity ) ;
191
- if ( isTransient . HasValue )
192
- return Task . FromResult < bool ? > ( isTransient ) ;
180
+ if ( entity . IsProxy ( ) )
181
+ return false ;
193
182
194
- if ( entity is INHibernateProxy proxy && proxy . HibernateLazyInitializer . IsUninitialized )
195
- {
196
- return Task . FromResult < bool ? > ( false ) ;
197
- }
183
+ if ( session . PersistenceContext . IsEntryFor ( entity ) )
184
+ return false ;
198
185
199
- // let the persister inspect the instance to decide
200
- return session . GetEntityPersister ( entityName , entity ) . IsTransientAsync ( entity , session , cancellationToken ) ;
201
- }
202
- catch ( System . Exception ex )
203
- {
204
- return Task . FromException < bool ? > ( ex ) ;
205
- }
186
+ // let the persister inspect the instance to decide
187
+ return session . Interceptor . IsTransient ( entity ) ??
188
+ await ( session . GetEntityPersister ( entityName , entity ) . IsTransientAsync ( entity , session , cancellationToken ) ) . ConfigureAwait ( false ) ;
206
189
}
207
190
208
191
/// <summary>
0 commit comments