本文整理汇总了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();
}
示例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();
}
}
示例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");
}
示例4: KeyManyToOneAndNormalizedPersister
public void KeyManyToOneAndNormalizedPersister()
{
Configuration cfg = new Configuration();
cfg
.AddClass(typeof(BaseClass))
.AddClass(typeof(KeyManyToOneClass))
.BuildSessionFactory().Close();
}
示例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;
}
示例6: DataAccesser
static DataAccesser()
{
//NHibernate's Config Initialize
config = new NHibernate.Cfg.Configuration();
config.Configure();
config.AddClass(typeof(Computer));
//SessionFactory Initialize
sessionFactory = config.BuildSessionFactory();
}
示例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));
}
示例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);
}
}
示例9: InitSessionFactory
private void InitSessionFactory(Type classType)
{
if (sessionFactory == null)
{
Configuration config = new Configuration();
config.AddClass(classType);
sessionFactory = config.BuildSessionFactory();
if (sessionFactory == null)
{
return;
}
}
}
示例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();
}
示例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);
}
示例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();
}
示例13: Configure
public void Configure()
{
Configuration cfg = new Configuration();
cfg.AddClass(typeof(Blog));
cfg.AddClass(typeof(BlogItem));
_sessions = cfg.BuildSessionFactory();
}
示例14: CreateConfiguration
private Configuration CreateConfiguration()
{
Configuration configuration = new Configuration();
Configure(configuration);
foreach (Type type in this.Mappings)
{
configuration.AddClass(type);
}
ApplyCacheSettings(configuration);
return configuration;
}
示例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));
}
}