public JoinExpression(InputExpression left, DbExpressionKind joinType, InputExpression right, VisitedExpression condition)
 {
     _left      = left;
     _joinType  = joinType;
     _right     = right;
     _condition = condition;
 }
예제 #2
0
        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();
            }
        }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
 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;
 }
예제 #7
0
 public JoinExpression(InputExpression left, DbExpressionKind joinType, InputExpression right, VisitedExpression condition)
 {
     _left = left;
     _joinType = joinType;
     _right = right;
     _condition = condition;
 }
예제 #8
0
 public AllColumnsExpression(InputExpression input)
 {
     _input = input;
 }
예제 #9
0
 public void Add(string asName, InputExpression exp)
 {
     Selects.Add(new NameAndInputExpression(asName, exp));
 }
예제 #10
0
 public PendingProjectsNode(string asName, InputExpression exp)
 {
     Selects.Add(new NameAndInputExpression(asName, exp));
 }
예제 #11
0
 public NameAndInputExpression(string asName, InputExpression exp)
 {
     AsName = asName;
     Exp = exp;
 }
예제 #12
0
 public AllColumnsExpression(InputExpression input)
 {
     _input = input;
 }
예제 #13
0
 public void Add(string asName, InputExpression exp)
 {
     Selects.Add(new NameAndInputExpression(asName, exp));
 }
예제 #14
0
 public PendingProjectsNode(string asName, InputExpression exp)
 {
     Selects.Add(new NameAndInputExpression(asName, exp));
 }
예제 #15
0
 public NameAndInputExpression(string asName, InputExpression exp)
 {
     AsName = asName;
     Exp    = exp;
 }
예제 #16
0
 public AllColumnsExpression(InputExpression input, ProjectionExpression projection)
 {
     _input = input;
     _projection = projection;
 }