我可以将流畅的映射与自动映射混合使用吗?如果是,怎么办?
最佳答案
只需定义您的映射和自动映射 ;-) 我无法说出确切的代码,因为我手边没有 VS,但您只需遵循 FNH 指南来创建这两种类型的映射,仅此而已,它们应该一起工作.
例子如下:
AutoPersistenceModel mappings = AutoMap
.AssemblyOf<Order>()
.IgnoreBase<BaseEntity>()
.Where(GetAutoMappingFilter)
.Conventions.Setup(GetConventions())
.Setup(GetSetup())
.UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
// this is for std mapping
//mappings.AddMappingsFromAssembly(
// typeof(Northwind.Data.NHibernateMappings.RouteConditionMap).Assembly);
最后一行有注释,因为我不需要标准映射。
但是,您为什么需要它?在自动映射中,您可以覆盖相同的内容。
关于c# - 使用 Fluent NHibernate 将流畅的映射与自动映射混合在一起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1882751/