18
18
using NHibernate . Proxy ;
19
19
using NHibernate . Util ;
20
20
using System . Collections . Generic ;
21
+ using System . Runtime . Serialization ;
21
22
22
23
namespace NHibernate . Type
23
24
{
@@ -98,9 +99,9 @@ public override async Task<object> ReplaceAsync(object original, object target,
98
99
{
99
100
return target ;
100
101
}
101
- if ( session . GetContextEntityIdentifier ( original ) == null && ( await ( ForeignKeys . IsTransientFastAsync ( associatedEntityName , original , session , cancellationToken ) ) . ConfigureAwait ( false ) ) . GetValueOrDefault ( ) )
102
+ if ( session . GetContextEntityIdentifier ( original ) == null && ( await ( ForeignKeys . IsTransientFastAsync ( _associatedEntityName , original , session , cancellationToken ) ) . ConfigureAwait ( false ) ) . GetValueOrDefault ( ) )
102
103
{
103
- object copy = session . Factory . GetEntityPersister ( associatedEntityName ) . Instantiate ( null ) ;
104
+ object copy = session . Factory . GetEntityPersister ( _associatedEntityName ) . Instantiate ( null ) ;
104
105
//TODO: should this be Session.instantiate(Persister, ...)?
105
106
copyCache . Add ( original , copy ) ;
106
107
return copy ;
@@ -129,7 +130,7 @@ public override async Task<object> ReplaceAsync(object original, object target,
129
130
/// <returns>
130
131
/// An instance of the object or <see langword="null" /> if the identifer was null.
131
132
/// </returns>
132
- public override sealed async Task < object > NullSafeGetAsync ( DbDataReader rs , string [ ] names , ISessionImplementor session , object owner , CancellationToken cancellationToken )
133
+ public sealed override async Task < object > NullSafeGetAsync ( DbDataReader rs , string [ ] names , ISessionImplementor session , object owner , CancellationToken cancellationToken )
133
134
{
134
135
cancellationToken . ThrowIfCancellationRequested ( ) ;
135
136
return await ( ResolveIdentifierAsync ( await ( HydrateAsync ( rs , names , session , owner , cancellationToken ) ) . ConfigureAwait ( false ) , session , owner , cancellationToken ) ) . ConfigureAwait ( false ) ;
@@ -144,10 +145,10 @@ protected async Task<object> ResolveIdentifierAsync(object id, ISessionImplement
144
145
{
145
146
cancellationToken . ThrowIfCancellationRequested ( ) ;
146
147
string entityName = GetAssociatedEntityName ( ) ;
147
- bool isProxyUnwrapEnabled = unwrapProxy && session . Factory
148
+ bool isProxyUnwrapEnabled = _unwrapProxy && session . Factory
148
149
. GetEntityPersister ( entityName ) . IsInstrumented ;
149
150
150
- object proxyOrEntity = await ( session . InternalLoadAsync ( entityName , id , eager , IsNullable && ! isProxyUnwrapEnabled , cancellationToken ) ) . ConfigureAwait ( false ) ;
151
+ object proxyOrEntity = await ( session . InternalLoadAsync ( entityName , id , _eager , IsNullable && ! isProxyUnwrapEnabled , cancellationToken ) ) . ConfigureAwait ( false ) ;
151
152
152
153
if ( proxyOrEntity . IsProxy ( ) )
153
154
{
@@ -178,21 +179,19 @@ public override Task<object> ResolveIdentifierAsync(object value, ISessionImplem
178
179
{
179
180
return Task . FromResult < object > ( null ) ;
180
181
}
181
- else
182
+
183
+ if ( IsNull ( owner , session ) )
182
184
{
183
- if ( IsNull ( owner , session ) )
184
- {
185
- return Task . FromResult < object > ( null ) ; //EARLY EXIT!
186
- }
185
+ return Task . FromResult < object > ( null ) ; //EARLY EXIT!
186
+ }
187
187
188
- if ( IsReferenceToPrimaryKey )
189
- {
190
- return ResolveIdentifierAsync ( value , session , cancellationToken ) ;
191
- }
192
- else
193
- {
194
- return LoadByUniqueKeyAsync ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName , value , session , cancellationToken ) ;
195
- }
188
+ if ( IsReferenceToPrimaryKey )
189
+ {
190
+ return ResolveIdentifierAsync ( value , session , cancellationToken ) ;
191
+ }
192
+ else
193
+ {
194
+ return LoadByUniqueKeyAsync ( GetAssociatedEntityName ( ) , _uniqueKeyPropertyName , value , session , cancellationToken ) ;
196
195
}
197
196
}
198
197
catch ( Exception ex )
0 commit comments