public JoinExpression(InputExpression left, DbExpressionKind joinType, InputExpression right, VisitedExpression condition) { _left = left; _joinType = joinType; _right = right; _condition = condition; }
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 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 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(); List <Type> expectedTypes = new List <Type>(); foreach (ColumnExpression column in pe.Projection.Arguments) { expectedTypes.Add(column.CLRType); } ((NpgsqlCommand)command).ExpectedTypes = expectedTypes.ToArray(); }
internal override void WriteSql(StringBuilder sqlText) { if (_from is InputExpression) { InputExpression input = (InputExpression)_from; if (!ForceSubquery && input.Projection == null && input.Where == null && input.Distinct == false && input.OrderBy == null && input.Skip == null && input.Limit == null) { // There is no point of writing // (SELECT ? FROM <from> AS <name>) AS <name> // so just write <from> AS <name> // <name> is always the same for both nodes // However, PostgreSQL needs a subquery in case we are in the right hand side of an Apply expression if (((FromExpression)input.From).Name != Name) { throw new ArgumentException(); } input.From.WriteSql(sqlText); } else { sqlText.Append("("); input.WriteSql(sqlText); sqlText.Append(") AS "); sqlText.Append(SqlBaseGenerator.QuoteIdentifier(_name)); } } else { bool wrap = !(_from is LiteralExpression || _from is ScanExpression); if (wrap) { sqlText.Append("("); } _from.WriteSql(sqlText); if (wrap) { sqlText.Append(")"); } sqlText.Append(" AS "); sqlText.Append(SqlBaseGenerator.QuoteIdentifier(_name)); } base.WriteSql(sqlText); }
public AllColumnsExpression(InputExpression input, ProjectionExpression projection) { _input = input; _projection = projection; }
public AllColumnsExpression(InputExpression input) { _input = input; }
public void Add(string asName, InputExpression exp) { Selects.Add(new NameAndInputExpression(asName, exp)); }
public PendingProjectsNode(string asName, InputExpression exp) { Selects.Add(new NameAndInputExpression(asName, exp)); }
public NameAndInputExpression(string asName, InputExpression exp) { AsName = asName; Exp = exp; }