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


C# ConventionModelMapper.CompileMappingForAllExplicitlyAddedEntities方法代码示例

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


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

示例1: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     configuration = new Configuration();
     configuration.SessionFactory()
                  .Integrate.Using<SQLiteDialect>()
                  .Connected.Using("Data source=testdb")
                  .AutoQuoteKeywords()
                  .LogSqlInConsole()
                  .EnableLogFormattedSql();
     var mapper = new ConventionModelMapper();
     mapper.Class<Foo>(cm => { });
     mapper.Class<Bar>(cm => { });
     CustomizeMapping(mapper);
     var mappingDocument = mapper.CompileMappingForAllExplicitlyAddedEntities();
     new XmlSerializer(typeof(HbmMapping)).Serialize(Console.Out, mappingDocument);
     configuration.AddDeserializedMapping(mappingDocument, "Mappings");
     new SchemaExport(configuration).Create(true, true);
     sessionFactory = configuration.BuildSessionFactory();
     using (var session = sessionFactory.OpenSession())
     using (var tx = session.BeginTransaction())
     {
         var foo = new Foo { Bars = CreateCollection() };
         foo.Bars.Add(new Bar { Data = 1 });
         foo.Bars.Add(new Bar { Data = 2 });
         id = session.Save(foo);
         tx.Commit();
     }
     sessionFactory.Statistics.IsStatisticsEnabled = true;
 }
开发者ID:polyzois,项目名称:NHibernate.Diegose,代码行数:29,代码来源:QueryableCollectionsFixture.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: GetSessionFactory

 public static ISessionFactory GetSessionFactory()
 {
     var config = new Configuration();
     config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using("Data source=nhtest.sqlite").AutoQuoteKeywords();
     var mapper = new ConventionModelMapper();
     Map(mapper);
     config.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), "Mappings");
     SchemaMetadataUpdater.QuoteTableAndColumns(config);
     new SchemaUpdate(config).Execute(false, true);
     return config.BuildSessionFactory();
 }
开发者ID:diegose,项目名称:NHPad,代码行数:11,代码来源:Configurator.cs

示例4: GetSessionFactory

 public static ISessionFactory GetSessionFactory()
 {
     AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
     var config = new Configuration();
     //config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using("Data source=nhtest.sqlite").AutoQuoteKeywords();
     config.SessionFactory().Integrate.Using<SQLiteDialect>().Connected.Using(String.Format("Data source={0}", Path.Combine(clientPath, "nhtest.sqlite"))).AutoQuoteKeywords();
     var mapper = new ConventionModelMapper();
     Map(mapper);
     config.AddDeserializedMapping(mapper.CompileMappingForAllExplicitlyAddedEntities(), "Mappings");
     SchemaMetadataUpdater.QuoteTableAndColumns(config);
     new SchemaUpdate(config).Execute(false, true);
     return config.BuildSessionFactory();
 }
开发者ID:marcoCasamento,项目名称:NHPad,代码行数:13,代码来源:Configurator.cs

示例5: GetMappingWithParentInCompo

		private HbmMapping GetMappingWithParentInCompo()
		{
			var mapper = new ConventionModelMapper();
			mapper.Class<MyClass>(x =>
			{
				x.Id(c => c.Id);
				x.Component(c => c.Compo);
			});
			mapper.Component<MyCompo>(x =>
			{
				x.Property(c => c.Something);
			});
			return mapper.CompileMappingForAllExplicitlyAddedEntities();
		}
开发者ID:owerkop,项目名称:nhibernate-core,代码行数:14,代码来源:ComponetsAccessorTests.cs

示例6: TestFixtureSetUp

 public void TestFixtureSetUp()
 {
     var configuration = new Configuration();
     configuration.SessionFactory()
                  .Integrate.Using<SQLiteDialect>()
                  .Connected.Using("Data source=testdb")
                  .AutoQuoteKeywords()
                  .LogSqlInConsole()
                  .EnableLogFormattedSql();
     var mapper = new ConventionModelMapper();
     MapClasses(mapper);
     var mappingDocument = mapper.CompileMappingForAllExplicitlyAddedEntities();
     new XmlSerializer(typeof(HbmMapping)).Serialize(Console.Out, mappingDocument);
     configuration.AddDeserializedMapping(mappingDocument, "Mappings");
     new SchemaExport(configuration).Create(true, true);
     sessionFactory = configuration.BuildSessionFactory();
 }
开发者ID:polyzois,项目名称:NHibernate.Diegose,代码行数:17,代码来源:LocalDateFixture.cs

示例7: InitSessionFactory

		private static void InitSessionFactory(ServiceContext context)
		{
			var cfg = new Configuration();

			var mapper = new ConventionModelMapper();
			
			mapper.BeforeMapClass +=
				(inspector, type, map) =>
				{
					var idProperty = type.GetProperty("Id");
					map.Id(idProperty, idMapper => { });
				};

			mapper.BeforeMapProperty +=
				(inspector, propertyPath, map) => map.Column(propertyPath.ToColumnName());

			mapper.BeforeMapManyToOne +=
				(inspector, propertyPath, map) => map.Column(propertyPath.ToColumnName() + "Id");

			foreach (var plugin in context.GetAllPlugins())
			{
				plugin.InitDbModel(mapper);
				cfg.AddAssembly(plugin.GetType().Assembly);
			}

			var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();


			cfg.DataBaseIntegration(dbConfig =>
			{
				dbConfig.Dialect<MsSqlCe40Dialect>();
				dbConfig.Driver<SqlServerCeDriver>();
				dbConfig.ConnectionStringName = "common";
			});

			cfg.AddDeserializedMapping(mapping, null);	//Loads nhibernate mappings

			var sessionFactory = cfg.BuildSessionFactory();
			context.InitSessionFactory(sessionFactory);
		}
开发者ID:3660628,项目名称:thinking-home,代码行数:40,代码来源:HomeApplication.cs

示例8: BuildConfiguration

        public Configuration BuildConfiguration()
        {
            var mapper = new ConventionModelMapper();

            CollectMappingContributorsAndApply(mapper);

            AR.RaiseOnMapperCreated(mapper, this);

            var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
            mapping.autoimport = Source.AutoImport;
            mapping.defaultlazy = Source.Lazy;

            if (Source.Debug) {
                try {
                    File.WriteAllText(
                        Path.Combine(
                            AppDomain.CurrentDomain.BaseDirectory,
                            Name + "mapping.hbm.xml"

                        ), mapping.AsString()
                    );
                } catch { /* just bail out */ }
            }

            AR.RaiseOnHbmMappingCreated(mapping, this);

            var cfg = new Configuration();

            if (Source.NamingStrategyImplementation != null)
                cfg.SetNamingStrategy((INamingStrategy) Activator.CreateInstance(Source.NamingStrategyImplementation));

            foreach(var key in Properties.AllKeys)
            {
                cfg.Properties[key] = Properties[key];
            }

            CollectAllContributorsAndRegister(cfg);

            cfg.AddMapping(mapping);

            AR.RaiseOnConfigurationCreated(cfg, this);

            return cfg;
        }
开发者ID:shosca,项目名称:ActiveRecord,代码行数:44,代码来源:SessionFactoryConfig.cs

示例9: BuildSessionFactory

 static Configuration BuildSessionFactory() {
     var config = new Configuration();
     config.SetProperties(CreateSessionFactoryDefaultProperties());
     config.SetProperty(NhCfgEnv.ConnectionString, "Data Source=db-dev4.gdepb.gov.cn;Initial Catalog=Test;Persist Security Info=True;User ID=udev;Password=devdev");
     var mapper = new ConventionModelMapper();
     mapper.AddMapping(new UserMapping());
     mapper.AddMapping(new RoleMapping());
     var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
     config.AddMapping(mapping);
     return config;
 }
开发者ID:beginor,项目名称:practice,代码行数:11,代码来源:UnitTest.cs


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