Skip to content

Commit e2b56ed

Browse files
David EllingsworthDavid Ellingsworth
David Ellingsworth
authored and
David Ellingsworth
committed
GH2552 Update acsync version of OneToOneType.IsModified.
1 parent b327a47 commit e2b56ed

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/NHibernate/Async/Type/OneToOneType.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,20 +80,21 @@ public override Task<bool> IsDirtyAsync(object old, object current, bool[] check
8080
return this.IsDirtyAsync(old, current, session, cancellationToken);
8181
}
8282

83-
public override Task<bool> IsModifiedAsync(object old, object current, bool[] checkable, ISessionImplementor session, CancellationToken cancellationToken)
83+
public override async Task<bool> IsModifiedAsync(object old, object current, bool[] checkable, ISessionImplementor session, CancellationToken cancellationToken)
8484
{
85-
if (cancellationToken.IsCancellationRequested)
86-
{
87-
return Task.FromCanceled<bool>(cancellationToken);
88-
}
89-
try
85+
cancellationToken.ThrowIfCancellationRequested();
86+
if (current == null)
9087
{
91-
return Task.FromResult<bool>(IsModified(old, current, checkable, session));
88+
return old != null;
9289
}
93-
catch (Exception ex)
90+
if (old == null)
9491
{
95-
return Task.FromException<bool>(ex);
92+
return true;
9693
}
94+
var oldIdentifier = IsIdentifier(old, session) ? old : await (GetIdentifierAsync(old, session, cancellationToken)).ConfigureAwait(false);
95+
var currentIdentifier = await (GetIdentifierAsync(current, session, cancellationToken)).ConfigureAwait(false);
96+
// the ids are fully resolved, so compare them with isDirty(), not isModified()
97+
return await (GetIdentifierOrUniqueKeyType(session.Factory).IsDirtyAsync(oldIdentifier, currentIdentifier, session, cancellationToken)).ConfigureAwait(false);
9798
}
9899

99100
public override async Task<object> HydrateAsync(DbDataReader rs, string[] names, ISessionImplementor session, object owner, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)