Skip to content

Commit 5ab793e

Browse files
committed
Revert some changs
1 parent 7c30da5 commit 5ab793e

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Orm/Xtensive.Orm/Core/AssociateProvider.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,17 @@ protected TResult GetAssociate<TKey1, TKey2, TAssociate, TResult>()
147147
var associate1 = CreateAssociate<TKey1, TAssociate>(out var foundFor);
148148
var associate2 = CreateAssociate<TKey2, TAssociate>(out foundFor);
149149
// Preferring non-null ;)
150-
var associate = associate1 ?? associate2 ?? PreferAssociate<TKey1, TKey2, TAssociate>(associate1, associate2);
150+
TAssociate associate = null;
151+
if (associate1 == null) {
152+
associate = associate2;
153+
}
154+
else if (associate2 == null) {
155+
associate = associate1;
156+
}
157+
else {
158+
// Both are non-null; preferring one of two
159+
associate = PreferAssociate<TKey1, TKey2, TAssociate>(associate1, associate2);
160+
}
151161
if (associate == null) {
152162
// Try to get complex associate (create it manually)
153163
associate = CreateCustomAssociate<TKey1, TKey2, TAssociate>();
@@ -161,9 +171,9 @@ protected TResult GetAssociate<TKey1, TKey2, TAssociate, TResult>()
161171
}
162172
throw new InvalidOperationException(string.Format(
163173
Strings.ExCantFindAssociate2, stringBuilder,
164-
typeof (TAssociate).GetShortName(),
165-
typeof (TKey1).GetShortName(),
166-
typeof (TKey2).GetShortName()));
174+
typeof(TAssociate).GetShortName(),
175+
typeof(TKey1).GetShortName(),
176+
typeof(TKey2).GetShortName()));
167177
}
168178
}
169179
return ConvertAssociate<TKey1, TKey2, TAssociate, TResult>(associate);

0 commit comments

Comments
 (0)