Skip to content

Commit 82d55f6

Browse files
committed
Makes check for key collection simpler
1 parent 4c2312e commit 82d55f6

1 file changed

Lines changed: 9 additions & 12 deletions

File tree

Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,18 +1263,9 @@ private Expression VisitExistsAsInclude(Expression source, LambdaExpression pred
12631263
var parameter = predicate.Parameters[0];
12641264
ProjectionExpression visitedSource;
12651265
using (state.CreateScope()) {
1266-
if (source.IsLocalCollection(context)) {
1267-
var sourceType = source.Type;
1268-
Type itemType = sourceType.IsGenericType
1269-
? itemType = sourceType.GetGenericArguments()[0]
1270-
: sourceType.IsArray
1271-
? sourceType.GetElementType()
1272-
: null;
1273-
1274-
if (itemType != null && itemType.IsAssignableFrom(typeof(Key))) {
1275-
var localCollectionKeyType = LocalCollectionKeyTypeExtractor.Extract((BinaryExpression) predicate.Body);
1276-
state.TypeOfEntityStoredInKey = localCollectionKeyType;
1277-
}
1266+
if (source.IsLocalCollection(context) && IsKeyCollection(source.Type)) {
1267+
var localCollectionKeyType = LocalCollectionKeyTypeExtractor.Extract((BinaryExpression) predicate.Body);
1268+
state.TypeOfEntityStoredInKey = localCollectionKeyType;
12781269
}
12791270
state.IncludeAlgorithm = IncludeAlgorithm.Auto;
12801271
visitedSource = VisitSequence(source);
@@ -1579,5 +1570,11 @@ private Expression VisitContainsNone(Expression setA, Expression setB, bool isRo
15791570
return VisitAll(setB, lambda, isRoot);
15801571
}
15811572
}
1573+
1574+
private bool IsKeyCollection(Type localCollectionType)
1575+
{
1576+
return (localCollectionType.IsArray && localCollectionType.GetElementType() == typeof(Key))
1577+
|| typeof(IEnumerable<Key>).IsAssignableFrom(localCollectionType);
1578+
}
15821579
}
15831580
}

0 commit comments

Comments
 (0)