本文整理汇总了C#中NHibernate.Dialect.Dialect.AppendLockHint方法的典型用法代码示例。如果您正苦于以下问题:C# Dialect.AppendLockHint方法的具体用法?C# Dialect.AppendLockHint怎么用?C# Dialect.AppendLockHint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Dialect.Dialect
的用法示例。
在下文中一共展示了Dialect.AppendLockHint方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 parms, Dialect.Dialect dialect)
{
tableName = PropertiesHelper.GetString(Table, parms, "hibernate_unique_key");
columnName = PropertiesHelper.GetString(Column, parms, "next_hi");
string schemaName = (string) parms[Schema];
if (schemaName != null && tableName.IndexOf(StringHelper.Dot) < 0)
{
tableName = schemaName + "." + tableName;
}
query =
"select " +
columnName +
" from " +
dialect.AppendLockHint(LockMode.Upgrade, tableName) +
dialect.ForUpdateString;
columnType = type as ValueTypeType;
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 SqlType[2] {columnSqlType, columnSqlType};
SqlStringBuilder builder = new SqlStringBuilder();
builder.Add("update " + tableName + " set ")
.Add(columnName)
.Add(" = ")
.Add(Parameter.Placeholder)
.Add(" where ")
.Add(columnName)
.Add(" = ")
.Add(Parameter.Placeholder);
updateSql = builder.ToSqlString();
}
示例2: 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 = Table.Qualify(catalogName, schemaName, tableName);
}
query = "select " + columnName + " from " + dialect.AppendLockHint(LockMode.Upgrade, tableName)
+ dialect.ForUpdateString;
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 SqlType[2] {columnSqlType, columnSqlType};
SqlStringBuilder builder = new SqlStringBuilder();
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();
}