当前位置: 首页>>代码示例>>C#>>正文


C# Dialect.Qualify方法代码示例

本文整理汇总了C#中NHibernate.Dialect.Dialect.Qualify方法的典型用法代码示例。如果您正苦于以下问题:C# Dialect.Qualify方法的具体用法?C# Dialect.Qualify怎么用?C# Dialect.Qualify使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NHibernate.Dialect.Dialect的用法示例。


在下文中一共展示了Dialect.Qualify方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Configure

		/// <summary>
		/// Configures the TableGenerator by reading the value of <c>table</c>, 
		/// <c>column</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"/> to help with Configuration.</param>
		public virtual void Configure(IType type, IDictionary<string, string> parms, Dialect.Dialect dialect)
		{
			tableName = PropertiesHelper.GetString(TableParamName, parms, DefaultTableName);
			columnName = PropertiesHelper.GetString(ColumnParamName, parms, DefaultColumnName);
			whereClause = PropertiesHelper.GetString(Where, parms, "");
			string schemaName = PropertiesHelper.GetString(PersistentIdGeneratorParmsNames.Schema, parms, null);
			string catalogName = PropertiesHelper.GetString(PersistentIdGeneratorParmsNames.Catalog, parms, null);

			if (tableName.IndexOf('.') < 0)
			{
				tableName = dialect.Qualify(catalogName, schemaName, tableName);
			}

			var selectBuilder = new SqlStringBuilder(100);
			selectBuilder.Add("select " + columnName)
				.Add(" from " + dialect.AppendLockHint(LockMode.Upgrade, tableName));
			if (string.IsNullOrEmpty(whereClause) == false)
			{
				selectBuilder.Add(" where ").Add(whereClause);
			}
			selectBuilder.Add(dialect.ForUpdateString);

			query = selectBuilder.ToString();

			columnType = type as PrimitiveType;
			if (columnType == null)
			{
				log.Error("Column type for TableGenerator is not a value type");
				throw new ArgumentException("type is not a ValueTypeType", "type");
			}

			// build the sql string for the Update since it uses parameters
			if (type is Int16Type)
			{
				columnSqlType = SqlTypeFactory.Int16;
			}
			else if (type is Int64Type)
			{
				columnSqlType = SqlTypeFactory.Int64;
			}
			else
			{
				columnSqlType = SqlTypeFactory.Int32;
			}

			parameterTypes = new[] {columnSqlType, columnSqlType};

			var builder = new SqlStringBuilder(100);
			builder.Add("update " + tableName + " set ")
				.Add(columnName).Add(" = ").Add(Parameter.Placeholder)
				.Add(" where ")
				.Add(columnName).Add(" = ").Add(Parameter.Placeholder);
			if (string.IsNullOrEmpty(whereClause) == false)
			{
				builder.Add(" and ").Add(whereClause);
			}

			updateSql = builder.ToSqlString();
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:66,代码来源:TableGenerator.cs


注:本文中的NHibernate.Dialect.Dialect.Qualify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。