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


C# Configuration.AddAuxiliaryDatabaseObject方法代码示例

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


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

示例1: GenerateSchema

        public static void GenerateSchema()
        {
            Configuration cfg = new Configuration();

            //cfg.SetProperty("nhibernate.envers.default_schema", "audit");

            cfg.AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));

            var mapper = new ModelMapper();
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());

            HbmMapping mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            cfg.AddMapping(mapping);

            cfg.AddAssembly(typeof(Model).Assembly);

            //cfg.IntegrateWithEnvers();

            cfg.Configure();

            new NHibernate.Tool.hbm2ddl.SchemaExport(cfg)
                .SetDelimiter(";")
                //.SetOutputFile("schema.sql")
                .Execute(false, true, false);
        }
开发者ID:rungwiroon,项目名称:NHibernate.Spatial,代码行数:25,代码来源:NHibernateHelper.cs

示例2: Main

        static void Main(string[] args)
        {
            SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory);

            var mapper = new ConventionModelMapper();

            mapper.Class<SomeAreaClass>(c =>
            {
                c.Property(x => x.Area, m =>
                {
                    m.Type<MsSql2008GeographyType>();
                    m.NotNullable(true);
                });
            });

            var cfg = new Configuration()

                .DataBaseIntegration(db =>
                {
                    db.ConnectionString = "YourConnectionString";
                    db.Dialect<MsSql2012GeographyDialect>();
                });

            cfg
                .AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());

            cfg
                .AddAuxiliaryDatabaseObject(new SpatialAuxiliaryDatabaseObject(cfg));

            new SchemaExport(cfg).Execute(false, true, false);
        }
开发者ID:danielcweber,项目名称:NHibernateSpatialBug,代码行数:31,代码来源:Program.cs

示例3: Bootstrap

        public static void Bootstrap()
        {
            var orm = MapConfiguration.GetObjectRelationalMapper();

            _mappings = MapConfiguration.GetMapings(orm);
            _configuration = GetConfiguration(_mappings);
            _configuration.AddAuxiliaryDatabaseObject(CreateHighLowScript(orm));
            SessionFactory = _configuration.BuildSessionFactory();

            _connection = MapConfiguration.BuildSchema(SessionFactory.OpenSession(), _configuration);

        }
开发者ID:RoyRV,项目名称:Training.MVC.Net,代码行数:12,代码来源:MemoryBootstrapper.cs

示例4: Bootstrap

        public static void Bootstrap()
        {
            _configuration = Fluently.Configure()
                    .Database(MsSqlCeConfiguration.Standard.ConnectionString(c => c.FromConnectionStringWithKey("FailTrackerData")))
                    .Mappings(m => m.AutoMappings.Add(
                    AutoMap.AssemblyOf<Issue>(new FailTrackerConfig()).UseOverridesFromAssemblyOf<IssueOverrides>()
                    )
                )
                .BuildConfiguration();
            _configuration.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject("alter table UserToProject add constraint PK_UserToProject primary key (User_id, Project_id)", ""));

            _sessionFactory = _configuration.BuildSessionFactory();
        }
开发者ID:williamflock,项目名称:Fail-Tracker,代码行数:13,代码来源:NHibernateBootstrapper.cs

示例5: FactoryProvider

        static FactoryProvider()
        {
            var modelInspector = new MySimpleModelInspector();
            Assert.IsNotNull(new Entity());
            var mapper = new ModelMapper(modelInspector);
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            mapper.BeforeMapClass += (mi, type, map) =>
                                     map.Id(idmap => idmap.Generator(Generators.HighLow,
                                                                     gmap => gmap.Params(new
                                                                                         	{
                                                                                         		table = "NextHighVaues",
                                                                                         		column = "NextHigh",
                                                                                         		max_lo = 100,
                                                                                         		where = String.Format("EntityName = '{0}'", type.Name.ToLowerInvariant())
                                                                                         	})));
            mapper.BeforeMapClass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
            mapper.BeforeMapJoinedSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
            mapper.BeforeMapUnionSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());

            mapper.BeforeMapProperty += (mi, propertyPath, map) =>
                                            {
                                                if (typeof(decimal).Equals(propertyPath.LocalMember.GetPropertyOrFieldType()))
                                                {
                                                    map.Type(NHibernateUtil.Currency);
                                                }
                                            };
            mapper.BeforeMapBag += (mi, propPath, map) =>
                                   	{
                                   		map.Cascade(Cascade.All.Include(Cascade.DeleteOrphans));
                                   		map.BatchSize(10);
                                   	};
            mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
            var domainMapping = mapper.CompileMappingForEachExplicitlyAddedEntity();
            domainMapping.WriteAllXmlMapping();
            var configuration = new Configuration();
            configuration.DataBaseIntegration(c =>
                                              	{
                                              		c.Dialect<MsSql2008Dialect>();
                                              		c.ConnectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=IntroNH;Integrated Security=True;Pooling=False";
                                              		c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
                                              		c.SchemaAction = SchemaAutoAction.Create;
                                              	});
            foreach(var mapping in domainMapping)
            {
                configuration.AddMapping(mapping);
            }
            configuration.AddAuxiliaryDatabaseObject(CreateHighLowScript(modelInspector, Assembly.GetExecutingAssembly().GetExportedTypes()));

            Factory=configuration.BuildSessionFactory();
        }
开发者ID:Marceli,项目名称:MVCNHibernate,代码行数:50,代码来源:FactoryProvider.cs

示例6: Bootstrap

        public static void Bootstrap()
        {
            var stdConfig = new Configuration();
            stdConfig.Configure();
            stdConfig.AddAuxiliaryDatabaseObject(new SimpleAuxiliaryDatabaseObject("alter table UserToProject add constraint PK_UserToProject primary key (User_id, Project_id)", ""));

            _configuration = Fluently.Configure(stdConfig)
                .Mappings(m => m.AutoMappings.Add(
                    AutoMap.AssemblyOf<Issue>(new FailTrackerConfig()).UseOverridesFromAssemblyOf<IssueOverrides>()
                    )
                )
                .BuildConfiguration();

            _sessionFactory = _configuration.BuildSessionFactory();
        }
开发者ID:rajeshpillai,项目名称:Fail-Tracker,代码行数:15,代码来源:NHibernateBootstrapper.cs

示例7: Main

        static void Main(string[] args)
        {
            XmlConfigurator.Configure();
              var log = LogManager.GetLogger(typeof (Program));

              NHibernateProfiler.Initialize();

              var cfg = new Configuration().Configure();

              cfg.AddAuxiliaryDatabaseObject(
            new SpatialAuxiliaryDatabaseObject(cfg));

              var sessionFactory = cfg.BuildSessionFactory();

              //Houston, TX
              var houstonTX = new Point(-95.383056, 29.762778);

              using (var session = sessionFactory.OpenSession())
              {
            using (var tx = session.BeginTransaction())
            {
              var query = session.CreateCriteria(
            typeof (StatePart))
            .Add(SpatialExpression.Contains(
              "Geometry", houstonTX));
              var part = query.UniqueResult<StatePart>();
              if (part == null)
              {
            log.InfoFormat("Houston, we have a problem.");
              }
              else
              {
            log.InfoFormat("Houston is in {0}",
              part.Name);
              }
              tx.Commit();
            }
              }
        }
开发者ID:akhuang,项目名称:NHibernate,代码行数:39,代码来源:Program.cs


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