Пример #1
0
        private void TranslateSelect(SelectExpression node)
        {
            Translate(node.Source);

            var projectValue = TranslateProjectValue(node.Selector);
            _stages.Add(new BsonDocument("$project", projectValue));
        }
 protected internal virtual Expression VisitSelect(SelectExpression node)
 {
     return node.Update(
         Visit(node.Source),
         Visit(node.Selector));
 }
        private BsonValue TranslateSelect(SelectExpression node)
        {
            var inputValue = TranslateValue(node.Source);
            var inValue = TranslateValue(FieldNamePrefixer.Prefix(node.Selector, "$" + node.ItemName));
            if (inputValue.BsonType == BsonType.String && inValue.BsonType == BsonType.String)
            {
                // if inputValue is a BsonString and inValue is a BsonString, 
                // then it is a simple field inclusion...
                // inValue is prefixed with a $${node.ItemName}, so we remove the itemName and the 2 $s.
                return inputValue.ToString() + inValue.ToString().Substring(node.ItemName.Length + 2);
            }

            return new BsonDocument("$map", new BsonDocument
            {
                { "input", inputValue },
                { "as", node.ItemName },
                { "in", inValue}
            });
        }
        private void VisitSelect(SelectExpression node)
        {
            Visit(node.Source);

            var projection = AggregateProjectionTranslator.TranslateProject(node.Selector);
            _stages.Add(new BsonDocument("$project", projection));
        }
        private BsonValue TranslateSelect(SelectExpression node)
        {
            if (node.Source is IFieldExpression && node.Selector is IFieldExpression)
            {
                var prefixName = ((IFieldExpression)node.Source).FieldName;
                return TranslateValue(FieldNamePrefixer.Prefix(node.Selector, prefixName));
            }

            var inputValue = TranslateValue(node.Source);
            var inValue = TranslateValue(FieldNamePrefixer.Prefix(node.Selector, "$" + node.ItemName));

            return new BsonDocument("$map", new BsonDocument
            {
                { "input", inputValue },
                { "as", node.ItemName },
                { "in", inValue}
            });
        }
 protected internal virtual Expression VisitSelect(SelectExpression node)
 {
     return(node.Update(
                Visit(node.Source),
                Visit(node.Selector)));
 }