本文整理汇总了C#中NHibernate.Cfg.Configuration.CreateMappings方法的典型用法代码示例。如果您正苦于以下问题:C# Configuration.CreateMappings方法的具体用法?C# Configuration.CreateMappings怎么用?C# Configuration.CreateMappings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NHibernate.Cfg.Configuration
的用法示例。
在下文中一共展示了Configuration.CreateMappings方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCfg
public static Configuration CreateCfg()
{
Configuration cfg = new Configuration();
cfg.Properties[NHibernate.Cfg.Environment.Dialect] = typeof(NHibernate.Dialect.GenericDialect).FullName;
cfg.AddAssembly(typeof(MyEntity).Assembly);
cfg.CreateMappings(new NHibernate.Dialect.GenericDialect());
return cfg;
}
示例2: AddTypeDef
public void AddTypeDef()
{
var configure = new Configuration()
.DataBaseIntegration(db => db.Dialect<MsSql2005Dialect>());
configure.TypeDefinition<TableHiLoGenerator>(c=>
{
c.Alias = "HighLow";
c.Properties = new {max_lo = 99};
});
var mappings = configure.CreateMappings(Dialect.Dialect.GetDialect(configure.Properties));
var typeDef = mappings.GetTypeDef("HighLow");
Assert.That(typeDef, Is.Not.Null);
Assert.That(typeDef.Parameters["max_lo"], Is.EqualTo("99"));
}
示例3: Main
private static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
var cfg = new Configuration();
cfg.Properties[Environment.Dialect] = typeof(GenericDialect).FullName;
cfg.Properties[Environment.ProxyFactoryFactoryClass] =
"NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle";
cfg.AddAssembly(typeof(MyEntity).Assembly);
cfg.CreateMappings(new GenericDialect());
var visualizerHost = new VisualizerDevelopmentHost(
cfg, typeof(CfgVisualizer));
visualizerHost.ShowVisualizer();
}
示例4: WhenMapHiloToDifferentSchemaThanClassThenIdHasTheMappedSchema
public void WhenMapHiloToDifferentSchemaThanClassThenIdHasTheMappedSchema()
{
var mapper = new ModelMapper();
mapper.Class<MyClass>(cm =>
{
cm.Schema("aSchema");
cm.Id(x => x.Id, idm => idm.Generator(Generators.HighLow, gm => gm.Params(new
{
table = "hilosequences",
schema="gSchema"
})));
});
var conf = new Configuration();
conf.DataBaseIntegration(x=> x.Dialect<MsSql2008Dialect>());
conf.AddDeserializedMapping(mapper.CompileMappingForAllExplicitAddedEntities(), "wholeDomain");
var mappings = conf.CreateMappings(Dialect.Dialect.GetDialect());
var pc = mappings.GetClass(typeof(MyClass).FullName);
((SimpleValue)pc.Identifier).IdentifierGeneratorProperties["schema"].Should().Be("gSchema");
}
示例5: VerifyMapping
private void VerifyMapping(HbmMapping mapping)
{
var dialect = new MsSql2008Dialect();
var configuration = new Configuration();
var mappings = configuration.CreateMappings(dialect);
mappings.DefaultAssembly = "NHibernate.Test";
mappings.DefaultNamespace = "NHibernate.Test.NHSpecificTest.NH1007";
var rootBinder = new MappingRootBinder(mappings, dialect);
rootBinder.Bind(mapping);
var employer = rootBinder.Mappings.GetClass("NHibernate.Test.NHSpecificTest.NH1007.Employer1");
var simpleValue = employer.Identifier as SimpleValue;
if (simpleValue != null)
{
Assert.That(simpleValue.IdentifierGeneratorStrategy, Is.EqualTo("guid"));
Assert.That(simpleValue.IdentifierGeneratorProperties, Is.Empty);
}
}