コード例 #1
0
 public Configuration BuildConfiguration <TDriver, TDialect, TContext>(BaseMapping mapping, String connectionStringName, Boolean updateSchema = false)
     where TDriver : IDriver
     where TDialect : Dialect
     where TContext : ICurrentSessionContext
 {
     return(this.BuildConfiguration <TDriver, TDialect, TContext, IBatcherFactory>(mapping, connectionStringName, updateSchema));
 }
コード例 #2
0
        public override Configuration BuildConfiguration <TDriver, TDialect, TContext, TBatcherFactory>(BaseMapping mapping, String connectionStringName, Boolean updateSchema = false)
        {
            Configuration cfg = this.CreateConfiguration()
                                .Configure();

            if (updateSchema == true)
            {
                SchemaExport export = new SchemaExport(cfg);
                export.Create(true, true);
            }

            return(cfg);
        }
コード例 #3
0
 public abstract Configuration BuildConfiguration <TDriver, TDialect, TContext, TBatcherFactory>(BaseMapping mapping, String connectionStringName, Boolean updateSchema = false)
     where TDriver : IDriver
     where TDialect : Dialect
     where TContext : ICurrentSessionContext
     where TBatcherFactory : IBatcherFactory;
コード例 #4
0
        public Configuration BuildConfiguration(Type driverType, Type dialectType, Type contextType, Type batcherFactoryType, BaseMapping mapping, String connectionStringName, Boolean updateSchema = false)
        {
            if (driverType == null)
            {
                driverType = typeof(IDriver);
            }

            if (dialectType == null)
            {
                dialectType = typeof(Dialect);
            }

            if (contextType == null)
            {
                contextType = typeof(ICurrentSessionContext);
            }

            if (batcherFactoryType == null)
            {
                batcherFactoryType = typeof(NonBatchingBatcherFactory);
            }

            return(ReflectionHelper.GetMethod <BaseConfiguration>(x => x.BuildConfiguration <IDriver, Dialect, ICurrentSessionContext, IBatcherFactory>(null, null, false)).MakeGenericMethod(driverType, dialectType, contextType, batcherFactoryType).Invoke(this, new Object[] { mapping, connectionStringName, updateSchema }) as Configuration);
        }
コード例 #5
0
        public override Configuration BuildConfiguration <TDriver, TDialect, TContext, TBatcherFactory>(BaseMapping mapping, String connectionStringName, Boolean updateSchema = false)
        {
            Configuration cfg = this.CreateConfiguration()
                                .DataBaseIntegration(db =>
            {
                db.ConnectionStringName = connectionStringName;
                db.Dialect <TDialect>();
                db.Driver <TDriver>();
                db.HqlToSqlSubstitutions = "true 1, false 0, yes 'Y', no 'N'";
                db.KeywordsAutoImport    = Hbm2DDLKeyWords.AutoQuote;
                db.SchemaAction          = (updateSchema == true) ? SchemaAutoAction.Update : SchemaAutoAction.Validate;
                db.LogFormattedSql       = true;
                db.BatchSize             = 100;

                if (typeof(TBatcherFactory) != typeof(IBatcherFactory))
                {
                    db.Batcher <TBatcherFactory>();
                }
            })
                                .SetProperty(NHibernate.Cfg.Environment.WrapResultSets, Boolean.TrueString)
                                .SetProperty(NHibernate.Cfg.Environment.GenerateStatistics, Boolean.FalseString)
                                .SetProperty(NHibernate.Cfg.Environment.QueryStartupChecking, Boolean.TrueString)
                                .SetProperty(NHibernate.Cfg.Environment.PrepareSql, Boolean.TrueString);

            if (typeof(TContext) != typeof(ICurrentSessionContext))
            {
                cfg = cfg.CurrentSessionContext <TContext>();
            }

            cfg = mapping.Map(cfg);

            return(cfg);
        }