本文整理汇总了C#中ModelMapper.CompileMappingForEachExplicitlyAddedEntity方法的典型用法代码示例。如果您正苦于以下问题:C# ModelMapper.CompileMappingForEachExplicitlyAddedEntity方法的具体用法?C# ModelMapper.CompileMappingForEachExplicitlyAddedEntity怎么用?C# ModelMapper.CompileMappingForEachExplicitlyAddedEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ModelMapper
的用法示例。
在下文中一共展示了ModelMapper.CompileMappingForEachExplicitlyAddedEntity方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PostProcessConfiguration
protected override void PostProcessConfiguration(global::NHibernate.Cfg.Configuration config)
{
base.PostProcessConfiguration(config);
if (FluentNhibernateMappingAssemblies != null)
{
// add any class mappings in the listed assemblies:
var mapper = new ModelMapper();
foreach (var asm in FluentNhibernateMappingAssemblies.Select(Assembly.Load))
{
mapper.AddMappings(asm.GetTypes());
}
foreach (var mapping in mapper.CompileMappingForEachExplicitlyAddedEntity())
{
config.AddMapping(mapping);
}
foreach (string assemblyName in FluentNhibernateMappingAssemblies)
{
config.AddMappingsFromAssembly(Assembly.Load(assemblyName));
}
}
}
示例2: CreateMapper
private IEnumerable<HbmMapping> CreateMapper()
{
var mapper = new ModelMapper();
mapper.AddMapping<XmlAsStringEntityMap>();
mapper.AddMapping<XmlEntityMap>();
mapper.AddMapping<BinaryEntityMap>();
mapper.AddMapping<ProtobufEntityMap>();
mapper.AddMapping<JsonEntityMap>();
return mapper.CompileMappingForEachExplicitlyAddedEntity();
}
示例3: FactoryProvider
static FactoryProvider()
{
var modelInspector = new MySimpleModelInspector();
Assert.IsNotNull(new Entity());
var mapper = new ModelMapper(modelInspector);
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
mapper.BeforeMapClass += (mi, type, map) =>
map.Id(idmap => idmap.Generator(Generators.HighLow,
gmap => gmap.Params(new
{
table = "NextHighVaues",
column = "NextHigh",
max_lo = 100,
where = String.Format("EntityName = '{0}'", type.Name.ToLowerInvariant())
})));
mapper.BeforeMapClass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
mapper.BeforeMapJoinedSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
mapper.BeforeMapUnionSubclass += (mi, t, map) => map.Table(t.Name.ToLowerInvariant());
mapper.BeforeMapProperty += (mi, propertyPath, map) =>
{
if (typeof(decimal).Equals(propertyPath.LocalMember.GetPropertyOrFieldType()))
{
map.Type(NHibernateUtil.Currency);
}
};
mapper.BeforeMapBag += (mi, propPath, map) =>
{
map.Cascade(Cascade.All.Include(Cascade.DeleteOrphans));
map.BatchSize(10);
};
mapper.AddMappings(Assembly.GetExecutingAssembly().GetExportedTypes());
var domainMapping = mapper.CompileMappingForEachExplicitlyAddedEntity();
domainMapping.WriteAllXmlMapping();
var configuration = new Configuration();
configuration.DataBaseIntegration(c =>
{
c.Dialect<MsSql2008Dialect>();
c.ConnectionString = @"Data Source=localhost\SQLEXPRESS;Initial Catalog=IntroNH;Integrated Security=True;Pooling=False";
c.KeywordsAutoImport = Hbm2DDLKeyWords.AutoQuote;
c.SchemaAction = SchemaAutoAction.Create;
});
foreach(var mapping in domainMapping)
{
configuration.AddMapping(mapping);
}
configuration.AddAuxiliaryDatabaseObject(CreateHighLowScript(modelInspector, Assembly.GetExecutingAssembly().GetExportedTypes()));
Factory=configuration.BuildSessionFactory();
}
示例4: PostProcessConfiguration
protected override void PostProcessConfiguration(NHibernate.Cfg.Configuration config)
{
base.PostProcessConfiguration(config);
// add any conformist mappings in the listed assemblies:
var mapper = new ModelMapper();
foreach (var asm in ConformistMappingAssemblies.Select(Assembly.Load))
{
mapper.AddMappings(asm.GetTypes());
}
foreach (var mapping in mapper.CompileMappingForEachExplicitlyAddedEntity())
{
config.AddMapping(mapping);
}
}
示例5: GetMappings
protected static HbmMapping GetMappings()
{
var mapper = new ModelMapper();
mapper.AddMapping<LocationMap>();
mapper.AddMapping<AddressMap>();
mapper.AddMapping<UserMap>();
mapper.CompileMappingForEachExplicitlyAddedEntity().WriteAllXmlMapping();
var mapping = mapper.CompileMappingForAllExplicitlyAddedEntities();
return mapping;
}
示例6: CanWriteMappingsReferencingProtectedProperty
public void CanWriteMappingsReferencingProtectedProperty()
{
var mapper = new ModelMapper();
mapper.Class<Entity>(rc =>
{
rc.Id(Entity.PropertyAccessExpressions.Id, m => m.Generator(Generators.GuidComb));
rc.Property(x => x.Name);
});
mapper.CompileMappingForEachExplicitlyAddedEntity().WriteAllXmlMapping();
}