Skip to content

Commit e847241

Browse files
committed
Make ForeignKeys.IsTransientFast not async
1 parent a13d0ac commit e847241

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/AsyncGenerator.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
applyChanges: true
66
analyzation:
77
methodConversion:
8+
- conversion: Ignore
9+
name: UnproxyForInitialized
10+
containingTypeName: ForeignKeys
811
- conversion: Ignore
912
name: UsePreparedStatement
1013
containingTypeName: DbTimestampType

src/NHibernate/Engine/ForeignKeys.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11

2-
using System;
3-
using System.Threading;
4-
using System.Threading.Tasks;
52
using NHibernate.Id;
63
using NHibernate.Persister.Entity;
74
using NHibernate.Proxy;
@@ -193,17 +190,21 @@ public static bool IsNotTransientSlow(string entityName, object entity, ISession
193190
return interceptorResult;
194191

195192
// let the persister inspect the instance to decide
196-
if (proxy != null)
197-
{
198-
// The persister only deals with unproxied entities.
199-
entity = proxy.HibernateLazyInitializer.GetImplementation();
200-
}
201-
193+
// The persister only deals with unproxied entities.
194+
entity = UnproxyForInitialized(proxy) ?? entity;
202195
return session
203196
.GetEntityPersister(
204197
entityName,
205198
entity)
206-
.IsTransient(entity, session);
199+
.IsTransient(entity);
200+
}
201+
202+
private static object UnproxyForInitialized(INHibernateProxy proxy)
203+
{
204+
return
205+
proxy?.HibernateLazyInitializer.IsUninitialized == false
206+
? proxy.HibernateLazyInitializer.GetImplementation()
207+
: null;
207208
}
208209

209210
/// <summary>

0 commit comments

Comments
 (0)