Beispiel #1
0
 public override string ToString()
 {
     if (ColumnAlias.HasValue())
     {
         return($"SqlExpression.Number({Value}), {ColumnAlias.Quoted()}");
     }
     else
     {
         return($"SqlExpression.Number({Value})");
     }
 }
Beispiel #2
0
 public override string ToString()
 {
     if (ToStringUseExpression || ColumnAlias.HasValue())
     {
         return($"SqlExpression.Null(), {ColumnAlias.Quoted()}");
     }
     else
     {
         return("SqlExpression.Null()");
     }
 }
Beispiel #3
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            string getFinalSqlStr = GetBinarySql(this);

            if (ColumnAlias.HasValue())
            {
                sb.Append($"SqlExpression.Raw(\"{getFinalSqlStr}\"), {ColumnAlias.Quoted()}");
            }
            else
            {
                sb.Append($"SqlExpression.Raw(\"{getFinalSqlStr}\")");
            }

            return(sb.ToString());
        }
Beispiel #4
0
 public override string ToString()
 {
     if (ToStringUseExpression)
     {
         return($"SqlExpression.Field({ColumnName.Quoted()}{(Table != null ? ", " + Table.ToString() : string.Empty)})");
     }
     else
     {
         if (Table == null && ColumnAlias.HasValue())
         {
             return($"SqlExpression.Field({ColumnName.Quoted()}){(ColumnAlias.HasValue() ? ", " + ColumnAlias.Quoted() : string.Empty)}");
         }
         else
         {
             return($"{ColumnName.Quoted()}{(Table != null ? ", " + Table.ToString() : string.Empty)}{(ColumnAlias.HasValue() ? ", " + ColumnAlias.Quoted() : string.Empty)}");
         }
     }
 }
        public override string ToString()
        {
            string tmpColumnName = ColumnName.Quoted();
            string fieldExpression;

            if (!tmpColumnName.HasValue())   // A literal may have been used
            {
                int intLiteral;
                if (int.TryParse(Convert.ToString(Value), out intLiteral))
                {
                    fieldExpression = $"SqlExpression.Number({Value})";
                }
                else
                {
                    fieldExpression = $"SqlExpression.String({Value.ToString().Quoted()})";
                }
            }
            else
            {
                fieldExpression = $"SqlExpression.Field({ColumnName.Quoted()}{(Table != null ? ", " + Table.ToString() : string.Empty)})";
            }

            if (ToStringUseExpression)
            {
                return($"SqlExpression.Function(SqlAggregationFunction.{Function.ToString()}, {fieldExpression})");
            }
            else
            {
                if (!ColumnAlias.HasValue())
                {
                    ColumnAlias = "col" + GetNextID();
                }

                if (Table == null)
                {
                    return($"SqlExpression.Function(SqlAggregationFunction.{Function.ToString()}, {fieldExpression}){(ColumnAlias.HasValue() ? ", " + ColumnAlias.Quoted() : string.Empty)}");
                }
                else
                {
                    return($"{ColumnName.Quoted()}{(Table != null ? ", " + Table.ToString() : string.Empty)}{(ColumnAlias.HasValue() ? ", " + ColumnAlias.Quoted() : string.Empty)}, SqlAggregationFunction.{Function.ToString()}");
                }
            }
        }
Beispiel #6
0
        public override string ToString()
        {
            string columnSqlOm;

            // Always use Coalesce
            //if (Columns.Count > 2) {
            string[] columnValues = new string[Columns.Count];

            for (int i = 0; i < Columns.Count; i++)
            {
                if (Columns[i] is gsFieldColumn)
                {
                    if (Columns[i].Table != null)
                    {
                        columnValues[i] = string.Concat(Columns[i].Table.TableName, ".", Columns[i].ColumnName);
                    }
                    else
                    {
                        columnValues[i] = Columns[i].ColumnName;
                    }
                }
                else if (Columns[i] is gsNumberColumn)
                {
                    columnValues[i] = Convert.ToString(Columns[i].Value);
                }
                else if (Columns[i] is gsStringColumn)
                {
                    columnValues[i] = string.Concat("'", Columns[i].Value, "'");
                }
                else
                {
                    throw new NotImplementedException($"Coalesce {Columns[i].GetType().Name} not supported");
                }
            }

            columnSqlOm = $"SqlExpression.Raw(\"COALESCE({(string.Join(", ", columnValues))})\"), {ColumnAlias.Quoted()}";
            //}
            //else {
            //    Columns.ForEach(col => col.ToStringUseExpression = true);
            //    columnSqlOm = $"SqlExpression.IfNull({Columns[0].ToString()}, {Columns[1].ToString()}), {ColumnAlias.Quoted()}";
            //}

            return(columnSqlOm);
        }