Exemplo n.º 1
0
        public override gsSelectColumn Parse()
        {
            gsSelectColumn selCol;

            if (_ScalarExpression is IntegerLiteral)
            {
                var intLiteral = _ScalarExpression as IntegerLiteral;
                selCol = new gsNumberColumn()
                {
                    Value       = intLiteral.Value,
                    ColumnAlias = ColumnAlias
                };
            }
            else if (_ScalarExpression is StringLiteral)
            {
                var stringLiteral = _ScalarExpression as StringLiteral;

                selCol = new gsStringColumn()
                {
                    Value       = stringLiteral.Value,
                    ColumnAlias = ColumnAlias
                };

                if (IsDate(Convert.ToString(stringLiteral.Value)))
                {
                    selCol            = new gsDateColumn();
                    selCol.ColumnName = "@sqlPrm" + SqlParameters.NewID();
                    selCol.Value      = $"DateTime.Parse({stringLiteral.Value.Quoted()})";

                    AddParameter(selCol, false);
                }
            }
            else if (_ScalarExpression is NullLiteral)
            {
                var intLiteral = _ScalarExpression as NullLiteral;
                selCol = new gsNullColumn()
                {
                    Value       = intLiteral.Value,
                    ColumnAlias = ColumnAlias
                };
            }
            else
            {
                throw new NotImplementedException($"Literal of type {_ScalarExpression.GetType().Name} not supported");
            }

            return(selCol);
        }