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


C# Configuration.AddClass方法代码示例

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


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

示例1: When_using_custom_bytecode_provider

 public When_using_custom_bytecode_provider()
 {
     //register the bytecode provider with NHibernate
     Initializer.RegisterBytecodeProvider(new EntityInjector());
     //configure NHibernate
     var config = new Configuration();
     config.AddClass(typeof(BasicCat));
     config.AddClass(typeof(InterfaceCat));
     config.AddClass(typeof(DependencyInjectionCat));
     //create the database
     var tool = new SchemaExport(config);
     tool.Execute(false, true, false);
     //build the session factory
     _sessionFactory = config.BuildSessionFactory();
 }
开发者ID:mynamespace,项目名称:NHibernate.Extensions,代码行数:15,代码来源:When_using_custom_bytecode_provider.cs

示例2: Main

        private static void Main()
        {
            // log4net Config
            XmlConfigurator.Configure();

            // NHibernate Config
            try {
                Configuration cfg = new Configuration();
            //				log.Info("Mapping Foo");
            //				cfg.AddClass(typeof (Foo));
                log.Info("Mapping Bar");
                cfg.AddClass(typeof (Bar));

                ISessionFactory factory = cfg.BuildSessionFactory();
                ISession session = factory.OpenSession();

            //				Foo foo = new Foo();
            //				foo.Nombre = "Foo" + DateTime.Now.Millisecond;
                Bar bar = new Bar();
                bar.Nombre = "Bar" + DateTime.Now.Millisecond;

                //foo.Bar = bar;
                //bar.Foo = foo;

                //session.Save(foo);

                bar.Id = 33;
                session.Update(bar);

            } catch (Exception ex) {
                Console.WriteLine(ex);
            } finally {
                Console.ReadLine();
            }
        }
开发者ID:BGCX261,项目名称:zonica-svn-to-git,代码行数:35,代码来源:Runner.cs

示例3: SystemTypeForDocumentId

        public void SystemTypeForDocumentId()
        {
            Configuration tempCfg = new Configuration();
            tempCfg.Configure();
            tempCfg.SetProperty("hibernate.search.default.directory_provider", typeof(RAMDirectoryProvider).AssemblyQualifiedName);
            tempCfg.AddClass(typeof(Gangster));
			Assert.Throws<HibernateException>(()=>tempCfg.BuildSessionFactory(),"Unable to guess IFieldBridge for Id");
        }
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:8,代码来源:UnresolvedBridgeTest.cs

示例4: KeyManyToOneAndNormalizedPersister

		public void KeyManyToOneAndNormalizedPersister()
		{
			Configuration cfg = new Configuration();
			cfg
				.AddClass(typeof(BaseClass))
				.AddClass(typeof(KeyManyToOneClass))
				.BuildSessionFactory().Close();
		}
开发者ID:jerry4781,项目名称:nhibernate-core,代码行数:8,代码来源:Fixture.cs

示例5: CreateSessionFactory

 private ISessionFactory CreateSessionFactory(NHibernateUnitOfWorkFacilityConfig config)
 {
     Configuration cfg = new Configuration().Configure(config.NHibernateConfigurationFile);
     foreach (Type mappedEntity in config.Entities) 
         cfg.AddClass(mappedEntity);
     
     ISessionFactory sessionFactory = cfg.BuildSessionFactory();
     EntitiesToRepositories.Register(Kernel, sessionFactory, typeof(NHRepository<>), config.IsCandidateForRepository);
     return sessionFactory;
 }
开发者ID:Dreameris,项目名称:.NET-Common-Library,代码行数:10,代码来源:MultipleNHibernateUnitOfWorkFacility.cs

示例6: DataAccesser

        static DataAccesser()
        {
            //NHibernate's Config Initialize
            config = new NHibernate.Cfg.Configuration();
            config.Configure();
            config.AddClass(typeof(Computer));

            //SessionFactory Initialize
            sessionFactory = config.BuildSessionFactory();
        }
开发者ID:hungtrinh81,项目名称:leonworkshop,代码行数:10,代码来源:DataAccesser.cs

示例7: When_using_session_auditor

 public When_using_session_auditor()
 {
     //configure NHibernate
     var config = new Configuration();
     config.AddClass(typeof(Cat));
     //create the database
     var tool = new SchemaExport(config);
     tool.Execute(false, true, false);
     //initialize context
     _currentScope = new Marshaler(config, typeof(ValidationInterceptor));
 }
开发者ID:mynamespace,项目名称:NHibernate.Extensions,代码行数:11,代码来源:When_using_session_auditor.cs

示例8: ClassMissingMappingFile

		public void ClassMissingMappingFile()
		{
			Configuration cfg = new Configuration();
			try
			{
				cfg.AddClass(typeof(A));
			}
			catch (MappingException me)
			{
				Assert.AreEqual("Resource not found: " + typeof(A).FullName + ".hbm.xml", me.Message);
			}
		}
开发者ID:tkellogg,项目名称:NHibernate3-withProxyHooks,代码行数:12,代码来源:AddClassFixture.cs

示例9: InitSessionFactory

 private void InitSessionFactory(Type classType)
 {
     if (sessionFactory == null)
         {
             Configuration config = new Configuration();
             config.AddClass(classType);
             sessionFactory = config.BuildSessionFactory();
             if (sessionFactory == null)
             {
                 return;
             }
         }
 }
开发者ID:kooyou,项目名称:TrafficFinesSystem,代码行数:13,代码来源:DBConnect.cs

示例10: FixtureSetup

        public void FixtureSetup()
        {
            BasicConfigurator.Configure();
            var cfg = new Configuration();
            cfg.AddProperties(new Dictionary<string, string> {
                {Environment.ConnectionProvider, typeof(DriverConnectionProvider).FullName},
                {Environment.Dialect, typeof(SQLiteDialect).FullName},
                {Environment.ConnectionDriver, typeof(SQLite20Driver).FullName},
                {Environment.ConnectionString, "Data Source=test.db;Version=3;New=True;"},
                //{"connection.release_mode", "on_close"},
            });

            cfg.AddClass(typeof (Simple));
            new SchemaExport(cfg).Create(true, true);
            sessionFactory = cfg.BuildSessionFactory();
        }
开发者ID:ruanzx,项目名称:mausch,代码行数:16,代码来源:SessionDirtyTests.cs

示例11: TestCreate

        public void TestCreate()
        {
            //NHibernate.Impl.SessionFactoryImpl
            var config = new Configuration();
            config.Configure("DatabaseCreate.cfg.xml");

            //config.AddAssembly(typeof (IModel).Assembly);
            //config.AddAssembly(typeof (User).Assembly);
            config.AddClass(typeof (User));

            Log.Debug("��ʼ�����");
            //config.AddAssembly(typeof())
            var schem = new SchemaExport(config);

            //schem.Drop(true, true);
            schem.Create(true, true);
        }
开发者ID:BGCX262,项目名称:zxd-svn-to-git,代码行数:17,代码来源:DatabaseTest.cs

示例12: ManualConfiguration

		public void ManualConfiguration() 
		{
			//log4net.Config.DOMConfigurator.ConfigureAndWatch( new FileInfo("log4net.cfg.xml") ); //use xml file instead of config
			Configuration cfg = new Configuration();
			IDictionary props = new Hashtable();

			props["hibernate.connection.provider"] = "NHibernate.Connection.DriverConnectionProvider"; 
			props["hibernate.dialect" ] = "NHibernate.Dialect.MsSql2000Dialect"; 
			props["hibernate.connection.driver_class" ] = "NHibernate.Driver.SqlClientDriver" ;
			props["hibernate.connection.connection_string"] = "Server=localhost;initial catalog=nhibernate;Integrated Security=SSPI" ;
		
			foreach( DictionaryEntry de in props ) 
			{
				cfg.SetProperty( de.Key.ToString(), de.Value.ToString() );
			}

			cfg.AddClass( typeof(Simple) );

			new SchemaExport( cfg ).Create( true, true );

			ISessionFactory factory = cfg.BuildSessionFactory();

		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:23,代码来源:ConfigurationFixture.cs

示例13: Configure

		public void Configure()
		{
			Configuration cfg = new Configuration();
			cfg.AddClass(typeof(Blog));
			cfg.AddClass(typeof(BlogItem));
			_sessions = cfg.BuildSessionFactory();
		}
开发者ID:rcarrillopadron,项目名称:nhibernate-1.0.2.0,代码行数:7,代码来源:BloggerFixture.cs

示例14: CreateConfiguration

		private Configuration CreateConfiguration()
		{
			Configuration configuration = new Configuration();

			Configure(configuration);

			foreach (Type type in this.Mappings)
			{
				configuration.AddClass(type);
			}

			ApplyCacheSettings(configuration);

			return configuration;
		}
开发者ID:knorrus,项目名称:nhcontrib,代码行数:15,代码来源:AbstractFixture.cs

示例15: InitializeIOC

        private void InitializeIOC()
        {
            NHibernateUnitOfWorkFacilityConfig[] configs = CreateRules();
            IoC.Initialize(
                new WindsorContainer()
                    .AddFacility("Multiple.Units.Of.Work", new MultipleNHibernateUnitOfWorkFacility(configs)));

            //load schemas to create databases
            schemas = new List<SchemaExport>();
            foreach (NHibernateUnitOfWorkFacilityConfig config in configs)
            {
                Configuration cfg = new Configuration().Configure(config.NHibernateConfigurationFile);
                foreach (Type entity in config.Entities)
                {
                    cfg.AddClass(entity);
                }
                schemas.Add(new SchemaExport(cfg));
            }
        }
开发者ID:brumschlag,项目名称:rhino-tools,代码行数:19,代码来源:MultipleNHibernateUnitOfWorkTestBase.cs


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