public SelectorExpression(string identifier, Type type) { if (identifier == null) throw new ArgumentNullException("identifier"); _identifier = identifier; _selectorType = CqlExpressionType.IdentifierSelector; _type = type; }
public SelectClauseExpression(IEnumerable<SelectorExpression> selectors, bool distinct) { _nodeType = CqlExpressionType.SelectColumns; _distinct = distinct; _selectors = selectors.AsReadOnly(); for (int i = 0; i < _selectors.Count; i++) _selectors[i].Ordinal = i; }
public TermExpression(ISet<TermExpression> terms) { if (terms == null || terms.Count == 0) throw new CqlLinqException("Empty lists are not allowed"); _type = typeof(ISet<>).MakeGenericType(terms.First().Type); _terms = terms.ToList().AsReadOnly(); _termType = CqlExpressionType.Set; }
public SelectorExpression(MethodInfo function, IEnumerable<SelectorExpression> arguments) { if (function.DeclaringType != typeof (CqlFunctions)) throw new ArgumentException("function must be a valid Cql Function"); _function = function; _arguments = arguments.AsReadOnly(); _type = function.ReturnType; _selectorType = CqlExpressionType.FunctionSelector; }
public OrderingExpression(SelectorExpression selector, CqlExpressionType orderType) { if (selector == null) throw new ArgumentNullException("selector"); if (orderType != CqlExpressionType.OrderAscending && orderType != CqlExpressionType.OrderDescending) throw new ArgumentException("ExpressionType must be OrderAscending or OrderDescending", "orderType"); _selector = selector; _order = orderType; }
/// <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; }
public TermExpression(Object value) { if (value == null) throw new ArgumentNullException("value"); ////check if type is a supported CQL type // if (!value.GetType().IsSupportedCqlType()) // throw new CqlLinqException(string.Format("Type {0} can't be coverted to a CQL value", value.GetType())); _type = value.GetType(); _termType = CqlExpressionType.Constant; _value = value; }
public SelectClauseExpression(bool count) { _nodeType = count ? CqlExpressionType.SelectCount : CqlExpressionType.SelectAll; }
public TermExpression(MethodInfo function, IEnumerable<TermExpression> arguments) { if (arguments == null) throw new ArgumentNullException("arguments"); _function = function; _terms = arguments.AsReadOnly(); _termType = CqlExpressionType.Function; _type = function.ReturnType; }
public TermExpression(IDictionary<TermExpression, TermExpression> terms) { if (terms == null || terms.Count == 0) throw new CqlLinqException("Empty dictionaries are not allowed"); var firstElement = terms.First(); _type = typeof(IDictionary<,>).MakeGenericType(firstElement.Key.Type, firstElement.Value.Type); _dictionaryTerms = terms.AsReadOnly(); _termType = CqlExpressionType.Map; }
public TermExpression(Type parameterType, int order) { _order = order; _type = parameterType; _termType = CqlExpressionType.Variable; }
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(); }
/// <summary> /// Shuffles identifier and term expression in the right order /// </summary> /// <param name="left"> The left. </param> /// <param name="right"> The right. </param> /// <param name="compareOp"> The compare operation. </param> /// <param name="compareOpSwitched"> The compare operation switched. </param> /// <returns> true expression if the relation is succesfully created </returns> /// <exception cref="CqlLinqException">Can't determine the (column) identfier for the CQL where relation /// or /// Error creating relation. Not able to detect the correct term to create the relation with.</exception> private Expression CreateRelation(Expression left, Expression right, CqlExpressionType compareOp, CqlExpressionType compareOpSwitched) { bool shuffled = false; if (left.GetType() != typeof(SelectorExpression)) { if (right.GetType() != typeof(SelectorExpression)) throw new CqlLinqException("Can't determine the column/token selector for the CQL where relation"); //swap expressions Expression temp = left; left = right; right = temp; shuffled = true; } if (right.GetType() != typeof(TermExpression)) throw new CqlLinqException("Could not detect term in the CQL where relation"); _relations.Add(new RelationExpression((SelectorExpression)left, shuffled ? compareOpSwitched : compareOp, (TermExpression)right)); return Expression.Constant(true); }