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


C# NHibernate.AddAuxiliaryDatabaseObject方法代码示例

本文整理汇总了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 }));
        }
开发者ID:Adiqq,项目名称:DDD-Playground,代码行数:23,代码来源:SessionFactory.cs

示例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 }));
        }
开发者ID:IdleLands,项目名称:IdleLandsRedux,代码行数:24,代码来源:IdConvention.cs


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