私は、設定より規約を強調するSharp Architecture Liteで遊んでおり、NHibernateがどのように機能するかを理解しようとしていますConventionModelMapper
。具体的には、以下のIsRootEntityメソッドとIsEntityメソッドの違いがわかりません(BTWEntity
は、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;
}
}
IsEntity
このメソッドは、どのクラスがDBへのマッピング/永続化に適格であるかをNHibernateに伝えるために使用されていることを収集します。しかし、私は一生の間、そのIsRootEntity
方法が何をするのか理解できません。周りのドキュメントConventionModelMapper
はひどくまばらです。