Ejemplo n.º 1
0
 private static string Quote(string column, Dialect.Dialect dialect)
 {
     if (column[0] == '`')
     {
         if (column[column.Length - 1] != '`')
         {
             throw new ArgumentException("missing ` in column " + column);
         }
         return(dialect.QuoteForAliasName(column.Substring(1, column.Length - 2)));
     }
     else
     {
         return(column);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sqlIdentifier"></param>
        /// <param name="dialect"></param>
        /// <returns></returns>
        public string ToAliasString(string sqlIdentifier, Dialect.Dialect dialect)
        {
            bool   isQuoted = dialect.IsQuoted(sqlIdentifier);
            string unquoted;

            if (isQuoted)
            {
                unquoted = dialect.UnQuote(sqlIdentifier);
            }
            else
            {
                unquoted = sqlIdentifier;
            }

            // Oracle doesn't like underscores at the start of identifiers (NH-320).
            // It should be safe to trim them here, because the aliases are postfixed
            // with a unique number anyway, so they won't collide.
            unquoted = unquoted.TrimStart('_');

            if (unquoted.Length > length)
            {
                unquoted = unquoted.Substring(0, length);
            }

            if (suffix != null)
            {
                unquoted += suffix;
            }

            if (isQuoted)
            {
                return(dialect.QuoteForAliasName(unquoted));
            }
            else
            {
                return(unquoted);
            }
        }