本文整理汇总了C#中NHibernate.Cfg.Configuration.AddMapping方法的典型用法代码示例。如果您正苦于以下问题:C# NHibernate.Cfg.Configuration.AddMapping方法的具体用法?C# NHibernate.Cfg.Configuration.AddMapping怎么用?C# NHibernate.Cfg.Configuration.AddMapping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了NHibernate.Cfg.Configuration.AddMapping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApplyMappings
void ApplyMappings(Configuration config)
{
var mapper = new ModelMapper();
mapper.AddMapping<OutboxEntityMap>();
config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
}
示例2: Build
/// <summary>
/// Builds the session factory with the given properties. Database is updated if updateSchema is set
/// </summary>
/// <param name="nhibernateProperties"></param>
/// <param name="updateSchema"></param>
/// <returns></returns>
public ISessionFactory Build(IDictionary<string, string> nhibernateProperties, bool updateSchema)
{
var scannedAssemblies = typesToScan.Select(t => t.Assembly).Distinct();
var nhibernateConfiguration = new Configuration().SetProperties(nhibernateProperties);
foreach (var assembly in scannedAssemblies)
nhibernateConfiguration.AddAssembly(assembly);
var mapping = new SagaModelMapper(typesToScan.Except(nhibernateConfiguration.ClassMappings.Select(x => x.MappedClass)));
HackIdIntoMapping(mapping);
nhibernateConfiguration.AddMapping(mapping.Compile());
ApplyDefaultsTo(nhibernateConfiguration);
if (updateSchema)
UpdateDatabaseSchemaUsing(nhibernateConfiguration);
try
{
return nhibernateConfiguration.BuildSessionFactory();
}
catch (Exception e)
{
if (e.InnerException != null)
throw new ConfigurationErrorsException(e.InnerException.Message, e);
throw;
}
}
示例3: SetupNHibernate
private void SetupNHibernate()
{
var config = new Configuration();
// where to get database mappings from
config.Configure(); // look at my App.config, find a hibernate-configuration section, and use those options to build session
var mapper = new ModelMapper();
// where to get class (table) mappings from
mapper.AddMapping<UserMap>();
config.AddMapping(mapper.CompileMappingForAllExplicitlyAddedEntities());
_sessionFactory = config.BuildSessionFactory();
}