protected override Expression VisitSubQuery(SubQueryExpression expression) { var queryType = expression.QueryModel.MainFromClause.ItemType; // Simple types if (TypeMappings.HasTypeMapping(queryType)) { var contains = expression.QueryModel.ResultOperators.OfType <ContainsResultOperator>().FirstOrDefault(); if (contains != null) { var @where = ContainmentWhereFragment.SimpleArrayContains(_parent._serializer, expression.QueryModel.MainFromClause.FromExpression, contains.Item.Value()); _register.Peek()(@where); return(null); } } if (expression.QueryModel.ResultOperators.Any(x => x is AnyResultOperator)) { var @where = new CollectionAnyContainmentWhereFragment(_parent._serializer, expression); _register.Peek()(@where); return(null); } return(base.VisitSubQuery(expression)); }
public void Parse() { var invalidOperators = _query.ResultOperators.Where(x => !ValidOperators.Contains(x.GetType())) .ToArray(); if (invalidOperators.Any()) { var names = invalidOperators.Select(x => x.GetType().Name).Join(", "); throw new NotSupportedException($"Marten does not yet support {names} operators in child collection queries"); } var members = FindMembers.Determine(_query.MainFromClause.FromExpression); var queryType = _query.SourceType(); var isPrimitive = TypeMappings.HasTypeMapping(queryType); Visit(_expression); // Simple types if (isPrimitive) { var contains = _query.ResultOperators.OfType <ContainsResultOperator>().FirstOrDefault(); if (contains != null) { var @where = ContainmentWhereFragment.SimpleArrayContains(members, _serializer, _query.MainFromClause.FromExpression, contains.Item.Value()); _registerFilter(@where); return; } } if (_query.ResultOperators.Any(x => x is AnyResultOperator)) { // Any() without predicate if (!_query.BodyClauses.Any()) { var @where_any_nopredicate = new CollectionAnyNoPredicateWhereFragment(members, _expression); _registerFilter(@where_any_nopredicate); return; } var @where = new CollectionAnyContainmentWhereFragment(members, _serializer, _expression); _registerFilter(@where); } }
protected override Expression VisitSubQuery(SubQueryExpression expression) { var queryType = expression.QueryModel.MainFromClause.ItemType; // Simple types if (TypeMappings.HasTypeMapping(queryType)) { var contains = expression.QueryModel.ResultOperators.OfType<ContainsResultOperator>().FirstOrDefault(); if (contains != null) { var @where = ContainmentWhereFragment.SimpleArrayContains(_parent._serializer, expression.QueryModel.MainFromClause.FromExpression, contains.Item.Value()); _register.Peek()(@where); return null; } } if (expression.QueryModel.ResultOperators.Any(x => x is AnyResultOperator)) { var @where = new CollectionAnyContainmentWhereFragment(_parent._serializer, expression); _register.Peek()(@where); return null; } return base.VisitSubQuery(expression); }