Represents a CQL terms (value)
Inheritance: System.Linq.Expressions.Expression
Exemple #1
0
        /// <summary>
        /// Replaces Variable terms with references to the correct argument
        /// </summary>
        /// <param name="node"></param>
        /// <returns></returns>
        public override Expression VisitTerm(TermExpression node)
        {
            if (node.NodeType != (ExpressionType)CqlExpressionType.Variable)
                throw new CqlLinqException("Unexpected type of term in a select clause: " + ((CqlExpressionType)node.NodeType).ToString());

            var argument = Expression.ArrayIndex(_arguments, Expression.Constant(node.Order));
            return Expression.Convert(argument, node.Type);
        }
        public override Expression VisitTerm(TermExpression term)
        {
            if (term.NodeType == (ExpressionType)CqlExpressionType.Variable)
            {
                //the term is a variable, add the original argument order nr to the map
                _parameterMap.Add(term.Order);
            }

            return term;
        }
        /// <summary>
        ///   Initializes a new instance of the <see cref="RelationExpression" /> class.
        /// </summary>
        /// <param name="selector"> The selector. </param>
        /// <param name="relation"> The relation. </param>
        /// <param name="term"> The term. </param>
        /// <exception cref="System.ArgumentNullException">selector
        ///   or
        ///   term</exception>
        public RelationExpression(SelectorExpression selector, CqlExpressionType relation, TermExpression term)
        {
            if (selector == null) throw new ArgumentNullException("selector");

            if (term == null)
                throw new ArgumentNullException("term");

            _selector = selector;
            _relation = relation;
            _term = term;
        }
Exemple #4
0
 private TermExpression(TermExpression original, IEnumerable<TermExpression> terms,
                        IDictionary<TermExpression, TermExpression> dictTerms)
 {
     _function = original.Function;
     _termType = original._termType;
     _type = original.Type;
     _value = original.Value;
     _terms = terms.AsReadOnly();
     _dictionaryTerms = dictTerms.AsReadOnly();
 }
Exemple #5
0
        public override Expression VisitTerm(TermExpression term)
        {
            base.VisitTerm(term);

            var builder = new StringBuilder();

            switch ((CqlExpressionType)term.NodeType)
            {
                case CqlExpressionType.Variable:
                    builder.Append("?");
                    break;

                case CqlExpressionType.Constant:
                    builder.Append(TypeSystem.ToStringValue(term.Value, CqlType.CreateType(term.Type)));
                    break;

                case CqlExpressionType.List:
                    {
                        builder.Append("[");
                        var elements = term.Terms.Select(value => _translations[value]).ToList();
                        builder.Append(string.Join(",", elements));
                        builder.Append("]");
                    }
                    break;

                case CqlExpressionType.Set:
                    {
                        builder.Append("{");
                        var elements = term.Terms.Select(value => _translations[value]).ToList();
                        builder.Append(string.Join(",", elements));
                        builder.Append("}");
                    }
                    break;

                case CqlExpressionType.Map:
                    {
                        builder.Append("{");
                        var elements =
                            term.DictionaryTerms.Select(
                                pair => string.Format("{0}:{1}", _translations[pair.Key], _translations[pair.Value])).
                                ToList();
                        builder.Append(string.Join(",", elements));
                        builder.Append("}");
                    }
                    break;

                case CqlExpressionType.Function:
                    builder.Append(term.Function.Name.ToLower());
                    builder.Append("(");
                    builder.Append(string.Join(",", term.Terms.Select(arg => _translations[arg])));
                    builder.Append(")");
                    break;

                default:
                    throw new CqlLinqException("Unexpected type of term encountered: " + term.NodeType.ToString());
            }

            _translations[term] = builder.ToString();
            return term;
        }
 /// <summary>
 ///   Visits the CQL term.
 /// </summary>
 /// <param name="node"> The node. </param>
 /// <returns> </returns>
 public virtual Expression VisitTerm(TermExpression node)
 {
     return base.VisitExtension(node);
 }