Esempio n. 1
0
 private string GetColumnRawValue(gsSelectColumn column)
 {
     if (column is gsFieldColumn)
     {
         if (column.Table == null)
         {
             return($"{column.ColumnName}");
         }
         else
         {
             if (column.Table.TableAlias.HasValue())
             {
                 return($"{column.Table.TableAlias}.{column.ColumnName}");
             }
             else
             {
                 return($"{column.Table.TableName}.{column.ColumnName}");
             }
         }
     }
     else if (column is gsNumberColumn)
     {
         return(Convert.ToString(column.Value));
     }
     else if (column is gsStringColumn)
     {
         return("'" + Convert.ToString(column.Value) + "'");
     }
     else if (column is gsUnaryColumn)
     {
         if ((column as gsUnaryColumn).UnaryType == gsUnaryType.Negative)
         {
             return("-" + Convert.ToString(column.Value));
         }
         return(Convert.ToString(column.Value));
     }
     else if (column is gsRawColumn || column is gsBinaryColumn || column is gsCoalesceColumn)
     {
         string rawSql = column.ToString();
         rawSql = rawSql.Replace("SqlExpression.Raw(\"", "");
         rawSql = rawSql.Remove(rawSql.Length - 4);
         return(rawSql);
     }
     else
     {
         throw new NotImplementedException($"BinaryColumn {column.GetType().Name} not supported");
     }
 }
Esempio n. 2
0
        private string ParseExpression(gsSelectColumn column)
        {
            string expressionStr;

            if (column is gsSubQueryColumn)
            {
                var subQryColumn = column as gsSubQueryColumn;
                subQryColumn.SubQuery.QryName = $"subQry{gsSelectQuery.GetNextID()}";

                InnerSqlOm += Environment.NewLine + subQryColumn.SubQuery.ToString();

                expressionStr = $"SqlExpression.SubQuery({subQryColumn.SubQuery.QryName})";
            }
            else
            {
                expressionStr = column.ToString();
            }

            return(expressionStr);
        }