Exemplo n.º 1
0
        // build the SELECT clause
        string BuildSelectClause()
        {
            StringBuilder sb = new StringBuilder();

            foreach (QueryField field in QueryFields)
            {
                if (field.Output)
                {
                    // add separator
                    if (sb.Length > 0)
                    {
                        sb.Append(",\r\n\t");
                    }

                    // add field expression ("table.column" or "colexpr")
                    string item = field.GetFullName(GroupBy);
                    sb.Append(item);

                    // add alias (use brackets to contain spaces, reserved words, etc)
                    if (!string.IsNullOrEmpty(field.Alias))
                    {
                        sb.AppendFormat(" AS {0}", OleDbSchema.BracketName(field.Alias));
                    }
                }
            }
            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Gets the full field name, including the parent table name and brackets.
        /// </summary>
        /// <returns>The full field name.</returns>
        public string GetFullName()
        {
            // return table.column string
            if (Column == "*" || _table.Columns.Contains(Column))
            {
                return(string.Format("{0}.{1}",
                                     OleDbSchema.GetFullTableName(_table),
                                     OleDbSchema.BracketName(Column)));
            }

            // column is not part of a table (e.g. expression)
            return(OleDbSchema.BracketName(Column));
        }