I'm playing around with Sharp Architecture Lite, which emphasizes convention over configuration, and trying to understand how the NHibernate ConventionModelMapper
works. Specifically, I can't tell the difference between the IsRootEntity & IsEntity methods below (BTW, Entity
is an abstract class that ships with Sharp Arch):
internal static class Conventions
{
public static void WithConventions(this ConventionModelMapper mapper, Configuration configuration) {
Type baseEntityType = typeof(Entity);
mapper.IsEntity((type, declared) => IsEntity(type));
mapper.IsRootEntity((type, declared) => baseEntityType.Equals(type.BaseType));
public static bool IsEntity(Type type) {
return typeof(Entity).IsAssignableFrom(type)
&& typeof(Entity) != type
&& !type.IsInterface;
}
}
I gather that the IsEntity
method is used to tell NHibernate which classes are eligible for mapping/persistence to the DB. However, I can't for the life of me figure out what the IsRootEntity
method does. The documentation around ConventionModelMapper
is woefully sparse.