Esempio n. 1
0
        /// <summary>
        /// Configures the SequenceGenerator by reading the value of <c>sequence</c> and
        /// <c>schema</c> from the <c>parms</c> parameter.
        /// </summary>
        /// <param name="type">The <see cref="IType"/> the identifier should be.</param>
        /// <param name="parms">An <see cref="IDictionary"/> of Param values that are keyed by parameter name.</param>
        /// <param name="dialect">The <see cref="Dialect.Dialect"/> to help with Configuration.</param>
        public virtual void Configure(IType type, IDictionary <string, string> parms, Dialect.Dialect dialect)
        {
            var  nativeSequenceName = PropertiesHelper.GetString(Sequence, parms, "hibernate_sequence");
            bool needQuote          = StringHelper.IsBackticksEnclosed(nativeSequenceName);
            bool isQuelified        = nativeSequenceName.IndexOf('.') > 0;

            if (isQuelified)
            {
                string qualifier = StringHelper.Qualifier(nativeSequenceName);
                nativeSequenceName = StringHelper.Unqualify(nativeSequenceName);
                nativeSequenceName = StringHelper.PurgeBackticksEnclosing(nativeSequenceName);
                sequenceName       = qualifier + '.' + (needQuote ? dialect.QuoteForTableName(nativeSequenceName) : nativeSequenceName);
            }
            else
            {
                nativeSequenceName = StringHelper.PurgeBackticksEnclosing(nativeSequenceName);
                sequenceName       = needQuote ? dialect.QuoteForTableName(nativeSequenceName) : nativeSequenceName;
            }
            string schemaName;
            string catalogName;

            parms.TryGetValue(Parameters, out parameters);
            parms.TryGetValue(PersistentIdGeneratorParmsNames.Schema, out schemaName);
            parms.TryGetValue(PersistentIdGeneratorParmsNames.Catalog, out catalogName);

            if (!isQuelified)
            {
                sequenceName = dialect.Qualify(catalogName, schemaName, sequenceName);
            }

            identifierType = type;
            sql            = new SqlString(dialect.GetSequenceNextValString(sequenceName));
        }
Esempio n. 2
0
 /// <summary>
 /// Gets the name of this Table in quoted form if it is necessary.
 /// </summary>
 /// <param name="dialect">
 /// The <see cref="Dialect.Dialect"/> that knows how to quote the Table name.
 /// </param>
 /// <returns>
 /// The Table name in a form that is safe to use inside of a SQL statement.
 /// Quoted if it needs to be, not quoted if it does not need to be.
 /// </returns>
 public string GetQuotedName(Dialect.Dialect dialect)
 {
     return(IsQuoted ? dialect.QuoteForTableName(name) : name);
 }
Esempio n. 3
0
 public void QuoteTableNameNeeded()
 {
     Assert.AreEqual(
         tableThatNeedsToBeQuoted[AfterQuoteIndex],
         d.QuoteForTableName(tableThatNeedsToBeQuoted[BeforeQuoteIndex]));
 }