本文整理汇总了C#中NHibernate.AddAuxiliaryDatabaseObject方法的典型用法代码示例。如果您正苦于以下问题:C# NHibernate.AddAuxiliaryDatabaseObject方法的具体用法?C# NHibernate.AddAuxiliaryDatabaseObject怎么用?C# NHibernate.AddAuxiliaryDatabaseObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate
的用法示例。
在下文中一共展示了NHibernate.AddAuxiliaryDatabaseObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateHighLowScript
public static void CreateHighLowScript(NHibernate.Cfg.Configuration config)
{
var script = new StringBuilder();
script.AppendFormat("DELETE FROM {0};", NHibernateHiLoIdentityTableName);
script.AppendLine();
script.AppendFormat("ALTER TABLE {0} ADD {1} VARCHAR(128) NOT NULL;", NHibernateHiLoIdentityTableName, TableColumnName);
script.AppendLine();
script.AppendFormat("CREATE NONCLUSTERED INDEX IX_{0}_{1} ON {0} ({1} ASC);", NHibernateHiLoIdentityTableName, TableColumnName);
script.AppendLine();
script.AppendLine("GO");
script.AppendLine();
foreach (var tableName in config.ClassMappings.Select(m => m.Table.Name).Distinct())
{
//strip [dbo].[TableName] to TableName
var match = Regex.Match(tableName, @"[^[\]]+(?=])", RegexOptions.RightToLeft);
script.AppendFormat(string.Format("INSERT INTO [{0}] ({1}, {2}) VALUES ('{3}',1);", NHibernateHiLoIdentityTableName, TableColumnName, NextHiValueColumnName, match.Value));
script.AppendLine();
}
config.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject(script.ToString(), null, new HashSet<string> { typeof(MsSql2000Dialect).FullName, typeof(MsSql2005Dialect).FullName, typeof(MsSql2008Dialect).FullName, typeof(MsSql2012Dialect).FullName }));
}
示例2: CreateHighLowScript
public static void CreateHighLowScript(NHibernate.Cfg.Configuration config)
{
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
var script = new StringBuilder();
script.AppendFormat("DELETE FROM {0};", NHibernateHiLoIdentityTableName);
script.AppendLine();
script.AppendFormat("ALTER TABLE {0} ADD {1} VARCHAR(128) NOT NULL;", NHibernateHiLoIdentityTableName, TableColumnName);
script.AppendLine();
script.AppendFormat("CREATE NONCLUSTERED INDEX IX_{0}_{1} ON {0} (Entity ASC);", NHibernateHiLoIdentityTableName, TableColumnName);
script.AppendLine();
script.AppendLine("GO");
script.AppendLine();
foreach (var tableName in config.ClassMappings.Select(m => m.Table.Name).Distinct())
{
script.AppendFormat(string.Format("INSERT INTO [{0}] ({1}, {2}) VALUES ('[{3}]',1);", NHibernateHiLoIdentityTableName, TableColumnName, NextHiValueColumnName, tableName));
script.AppendLine();
}
config.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject(script.ToString(), null, new HashSet<string> { typeof(PostgreSQL82Dialect).FullName, typeof(SQLiteDialect).FullName, typeof(MsSql2008Dialect).FullName }));
}