Skip to content

Commit 79fb0d5

Browse files
committed
In/Contains also supports Key[] collections
1 parent c2673b5 commit 79fb0d5

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,11 +1263,18 @@ 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-
(source.Type.IsGenericType && source.Type.GetGenericArguments()[0].IsAssignableFrom(typeof (Key))) ||
1268-
(source.Type.IsAssignableFrom(typeof (Key)))) {
1269-
var localCollecctionKeyType = LocalCollectionKeyTypeExtractor.Extract((BinaryExpression)predicate.Body);
1270-
state.TypeOfEntityStoredInKey = localCollecctionKeyType;
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+
}
12711278
}
12721279
state.IncludeAlgorithm = IncludeAlgorithm.Auto;
12731280
visitedSource = VisitSequence(source);

0 commit comments

Comments
 (0)