シャープアーキテクチャーライト(Sharp Architecture Lite)は、設定に関する慣例を強調し、NHibernate ConventionModelMapper
の仕組みを理解しようとしています。具体的には、私は& IsEntity方法以下IsRootEntity間の違いを見分けることができない(BTW、Entity
抽象クラスシャープアーチに付属ある):私は、IsEntity
方法はNHibernateのに通知するために使用されていることを集めるNHibernate ConventionModelMapper; IsRootEntityとIsEntityの違いは何ですか?
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;
}
}
はクラスはDBへのマッピング/永続性の対象となります。しかし、私の人生のためには、IsRootEntity
メソッドが何をしているのか理解できません。 ConventionModelMapper
のドキュメントは悲惨です。あなたはケースを検討している場合
あなたのケースでは、IsEntity()はAとBに対してtrueを返すべきですが、IsRootEntityはB. Entity()はIsEntity()のサブセットでなければならず、クラスの継承のマッピングを制御するためにのみ使用されます。たとえば、AとBの両方でIsRootEntityをtrueに設定すると、すべてのプロパティを2つの別々のクラスとしてマップします。 – dotjoe