private OperatorExpression(Operator op, bool useNewPrecedences, VisitedExpression left, VisitedExpression right) { this.op = op; this.useNewPrecedences = useNewPrecedences; this.left = left; this.right = right; }
public JoinExpression(InputExpression left, DbExpressionKind joinType, InputExpression right, VisitedExpression condition) { _left = left; _joinType = joinType; _right = right; _condition = condition; }
OperatorExpression(Operator op, bool useNewPrecedences, [CanBeNull] VisitedExpression left, [CanBeNull] VisitedExpression right) { _op = op; _useNewPrecedences = useNewPrecedences; _left = left; _right = right; }
public override void BuildCommand(DbCommand command) { System.Diagnostics.Debug.Assert(command is NpgsqlCommand); System.Diagnostics.Debug.Assert(_commandTree.Query is DbProjectExpression); VisitedExpression ve = _commandTree.Query.Accept(this); System.Diagnostics.Debug.Assert(ve is InputExpression); InputExpression pe = (InputExpression)ve; command.CommandText = pe.ToString(); // We retrieve all strings as unknowns in text format in the case the data types aren't really texts ((NpgsqlCommand)command).UnknownResultTypeList = pe.Projection.Arguments.Select(a => ((PrimitiveType)((ColumnExpression)a).ColumnType.EdmType).PrimitiveTypeKind == PrimitiveTypeKind.String).ToArray(); // We must treat sbyte and DateTimeOffset specially so the value is read correctly if (pe.Projection.Arguments.Any(a => { var kind = ((PrimitiveType)((ColumnExpression)a).ColumnType.EdmType).PrimitiveTypeKind; return(kind == PrimitiveTypeKind.SByte || kind == PrimitiveTypeKind.DateTimeOffset); })) { ((NpgsqlCommand)command).ObjectResultTypes = pe.Projection.Arguments.Select(a => { var kind = ((PrimitiveType)((ColumnExpression)a).ColumnType.EdmType).PrimitiveTypeKind; if (kind == PrimitiveTypeKind.SByte) { return(typeof(sbyte)); } else if (kind == PrimitiveTypeKind.DateTimeOffset) { return(typeof(DateTimeOffset)); } return(null); }).ToArray(); } }
public static OperatorExpression Build(Operator op, bool useNewPrecedences, VisitedExpression left, VisitedExpression right) { if (op.UnaryType == Operator.UnaryTypes.Binary) { return(new OperatorExpression(op, useNewPrecedences, left, right)); } throw new InvalidOperationException("Unary operator with two operands"); }
public void AppendSet(VisitedExpression property, VisitedExpression value) { Append(_setSeperatorRequired ? "," : " SET "); Append(property); Append("="); Append(value); _setSeperatorRequired = true; }
public void AppendGroupingKey(VisitedExpression key) { if (_requiresGroupSeperator) { Append(","); } Append(key); _requiresGroupSeperator = true; }
public void AppendSort(VisitedExpression sort, bool ascending) { if (_requiresOrderSeperator) { Append(","); } Append(sort); Append(ascending ? " ASC " : " DESC "); _requiresOrderSeperator = true; }
public override void BuildCommand(DbCommand command) { System.Diagnostics.Debug.Assert(command is NpgsqlCommand); System.Diagnostics.Debug.Assert(_commandTree.Query is DbProjectExpression); VisitedExpression ve = _commandTree.Query.Accept(this); System.Diagnostics.Debug.Assert(ve is InputExpression); InputExpression pe = (InputExpression)ve; command.CommandText = pe.ToString(); }
public FromExpression(VisitedExpression from, string name) { _from = from; if (name != null) { _name = name; } else { _name = "ALIAS" + _uniqueName++; } }
public static OperatorExpression Build(Operator op, bool useNewPrecedences, VisitedExpression exp) { switch (op.UnaryType) { case Operator.UnaryTypes.Prefix: return(new OperatorExpression(op, useNewPrecedences, null, exp)); case Operator.UnaryTypes.Postfix: return(new OperatorExpression(op, useNewPrecedences, exp, null)); default: throw new InvalidOperationException("Binary operator with one operand"); } }
public static OperatorExpression Build(Operator op, bool useNewPrecedences, VisitedExpression exp) { if (op.UnaryType == Operator.UnaryTypes.Prefix) { return(new OperatorExpression(op, useNewPrecedences, null, exp)); } else if (op.UnaryType == Operator.UnaryTypes.Postfix) { return(new OperatorExpression(op, useNewPrecedences, exp, null)); } else { throw new InvalidOperationException("Binary operator with one operand"); } }
public override void BuildCommand(DbCommand command) { System.Diagnostics.Debug.Assert(command is NpgsqlCommand); System.Diagnostics.Debug.Assert(_commandTree.Query is DbProjectExpression); VisitedExpression ve = _commandTree.Query.Accept(this); System.Diagnostics.Debug.Assert(ve is ProjectionExpression); ProjectionExpression pe = (ProjectionExpression)ve; command.CommandText = pe.ToString(); List <Type> expectedTypes = new List <Type>(); foreach (var column in pe.Columns) { expectedTypes.Add(column.CLRType); } ((NpgsqlCommand)command).ExpectedTypes = expectedTypes.ToArray(); }
/// <summary> /// Negates an expression. /// If possible, replaces the operator of exp if exp is a negatable OperatorExpression, /// else return a new OperatorExpression of type Not that wraps exp. /// </summary> public static VisitedExpression Negate(VisitedExpression exp, bool useNewPrecedences) { OperatorExpression expOp = exp as OperatorExpression; if (expOp != null) { Operator op = expOp.op; Operator newOp = null; if (Operator.NegateDict.TryGetValue(op, out newOp)) { expOp.op = newOp; return(expOp); } if (expOp.op == Operator.Not) { return(expOp.right); } } return(OperatorExpression.Build(Operator.Not, useNewPrecedences, exp)); }
public void AppendTarget(VisitedExpression target) { Append(target); }
public void AppendWhere(VisitedExpression where) { Append(" WHERE "); Append(where); }
public ExistsExpression(VisitedExpression argument) { _argument = argument; }
public IsNullExpression(VisitedExpression argument) { _argument = argument; }
public static OperatorExpression Build(Operator op, VisitedExpression exp) { if (op.UnaryType == Operator.UnaryTypes.Prefix) { return new OperatorExpression(op, null, exp); } else if (op.UnaryType == Operator.UnaryTypes.Postfix) { return new OperatorExpression(op, exp, null); } else { throw new InvalidOperationException("Binary operator with one operand"); } }
public NegatableBooleanExpression(DbExpressionKind booleanOperator, VisitedExpression left, VisitedExpression right) { _booleanOperator = booleanOperator; _left = left; _right = right; }
internal void AddArgument(VisitedExpression visitedExpression) { _args.Add(visitedExpression); }
/// <summary> /// Negates an expression. /// If possible, replaces the operator of exp if exp is a negatable OperatorExpression, /// else return a new OperatorExpression of type Not that wraps exp. /// </summary> public static VisitedExpression Negate(VisitedExpression exp) { OperatorExpression expOp = exp as OperatorExpression; if (expOp != null) { Operator op = expOp.op; Operator newOp = null; if (Operator.NegateDict.TryGetValue(op, out newOp)) { expOp.op = newOp; return expOp; } if (expOp.op == Operator.Not) { return expOp.right; } } return OperatorExpression.Build(Operator.Not, exp); }
private OperatorExpression(Operator op, VisitedExpression left, VisitedExpression right) { this.op = op; this.left = left; this.right = right; }
internal FunctionExpression AddArgument(VisitedExpression visitedExpression) { _args.Add(visitedExpression); return this; }
public new LiteralExpression Append(VisitedExpression expresion) { base.Append(expresion); return this; }
internal void And(VisitedExpression andAlso) { _where = OperatorExpression.Build(Operator.And, _where, andAlso); }
internal void And(VisitedExpression andAlso) { _where = new BooleanExpression("AND", _where, andAlso); }
public LimitExpression(VisitedExpression arg) { _arg = arg; }
public SkipExpression(VisitedExpression arg) { _arg = arg; }
public void AppendGroupingKey(VisitedExpression key) { if (_requiresGroupSeperator) Append(","); Append(key); _requiresGroupSeperator = true; }
public static OperatorExpression Build(Operator op, VisitedExpression left, VisitedExpression right) { if (op.UnaryType == Operator.UnaryTypes.Binary) { return new OperatorExpression(op, left, right); } else { throw new InvalidOperationException("Unary operator with two operands"); } }
public BooleanExpression(string booleanOperator, VisitedExpression left, VisitedExpression right) { _booleanOperator = booleanOperator; _left = left; _right = right; }
public NegateExpression(VisitedExpression argument) { _argument = argument; Negated = true; }
public new void Append(VisitedExpression expresion) { base.Append(expresion); }
public CastExpression(VisitedExpression value, string type) { _value = value; _type = type; }
public CombinedProjectionExpression(VisitedExpression first, string setOperator, VisitedExpression second) { _first = first; _setOperator = setOperator; _second = second; }
public void AppendSet(VisitedExpression property, VisitedExpression value) { if (_setSeperatorRequired) Append(","); else Append(" SET "); Append(property); Append("="); Append(value); _setSeperatorRequired = true; }
public void Append(VisitedExpression expression) { ExpressionList.Add(expression); }
public WhereExpression(VisitedExpression where) { _where = where; }
public void AppendFrom(VisitedExpression from) { Append(from); }
public ColumnExpression(VisitedExpression column, string columnName, TypeUsage columnType) { _column = column; _columnName = columnName; _columnType = columnType; }
public void AppendSort(VisitedExpression sort, bool ascending) { if (_requiresOrderSeperator) Append(","); Append(sort); if (ascending) Append(" ASC "); else Append(" DESC "); _requiresOrderSeperator = true; }