Override Fluent Mapping
I have a mapping assembly called MyApp.Mapping.dll which maps lots of entities and I also have the following mapping:
public class UserMap : ClassMap<User>
//(...)
HasManyToMany(p => p.Roles).Not.LazyLoad()
//(...)
The Roles association is mapped as not lazyload for whatever reason.开发者_开发技巧
For a ver specific reason I want to Lazy map this association and for what I have researched, it is not possible to fetch a eager mapped association as Lazy in a Criteria.
So the question is:
Can I create another mapping class in another assembly that overrides UserMap mapping so that I can reuse MyApp.Mappings.dll for other entities?
you can build up the configuration object and then
var roles = config
.GetClassMapping(typeof(User))
.GetProperty("Roles");
roles.IsLazy = false;
config.BuildSessionFactory();
Hope that helps
精彩评论