2010-04-28 4 views
0

이전 서브 클래스 구문에서는이를 수행하는 방법을 보았지만 새 클래스에서는 SubclassMap 구문을 사용하지 않았습니다.Fluent Nhibernate가 포함 된 중첩 된 하위 클래스

기본적으로 테이블에 여러 개의 식별자가 있으며 FNH로이를 수행하는 방법을 알아야합니다.

감사합니다, 샘 우리는 학습자, 평가자, 관리자, 관리자 등이 여기

로 그에서 기본 클래스 사용자 및 많은 파생 클래스가

+0

어떻게 사용했는지, 엔티티 설계 방법에 대한 몇 가지 예를 보여줄 수 있습니까? –

답변

0

가 UserMap입니다

public class UserMap : ClassMap<User> 
{ 
    public UserMap() 
    { 
     this.Id(x => x.Id); 

     this.Map(x => x.Active); 

     this.Component(
      x => x.Address, 
      m => 
      { 
       m.Map(x => x.Address1).Length(512); 
       m.Map(x => x.Address2); 
       m.Map(x => x.Address3); 
       m.Map(x => x.Address4); 
       m.Map(x => x.City); 
       m.Map(x => x.County); 
       m.Map(x => x.PostCode); 
       m.References(x => x.Country); 
      }); 

     this.References(x => x.CreatedBy); 

     this.Map(x => x.CreatedDate).Not.Nullable(); 

     this.Map(x => x.DeletedDate); 

     this.References(x => x.DeletedBy); 

     this.Map(x => x.Email); 

     this.Map(x => x.Fax); 

     this.Map(x => x.FirstName); 

     this.References(x => x.Gender); 

     this.Map(x => x.LastName); 

     this.Map(x => x.LoginName).UniqueKey("ui_loginName").Not.Nullable(); 

     this.Map(x => x.MiddleName); 

     this.Map(x => x.Password); 

     this.DiscriminateSubClassesOnColumn("className").Length(64); 
    } 
} 

및 관리자의 예

public class ManagerMap : SubclassMap<Manager> 
{ 
    #region Constructors and Destructors 

    /// <summary> 
    /// Initializes a new instance of the <see cref="ManagerMap"/> class. 
    /// </summary> 
    public ManagerMap() 
    { 
     this.HasManyToMany(x => x.Organisation) 
      .ParentKeyColumn("userId") 
      .ChildKeyColumn("organisationId") 
      .Table("UserOrganisations"); 

     this.HasMany(x => x.Learners) 
      .KeyColumn("managerId") 
      .AsBag(); 
    } 

    #endregion 
} 

희망 사항 너를 도울 것이다.

관련 문제