예제 #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);
     }
 }
예제 #2
0
파일: Alias.cs 프로젝트: ImanRezaeipour/GTS
        /// <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);
            }
        }