2010-06-24 4 views
1

를 설정되어 있지 않습니다. 나는 CompanyEntity로드가 있고 ComId 속성을 액세스 할 때성 액티브 JoinedKey은 내가 사용하고

[ActiveRecord("entity"), JoinedBase] 
public class Entity : ActiveRecordBase 
{ 
    ... 
    private int id; 

    [PrimaryKey] 
    private int Id 
    { 
     get { return id; } 
     set { id = value; } 
    } 
} 

[ActiveRecord("entitycompany")] 
public class CompanyEntity : Entity 
{ 
    private int comp_id; 

    [JoinedKey("comp_id")] 
    public int CompId 
    { 
     get { return comp_id; } 
     set { comp_id = value; } 
    } 
    .... 
} 

지금은 항상 0이지만, 상속 아이디 속성에 올바른 값이 포함되어 있습니다.

편집 :

나는 아마 우리의 엔티티가 자동으로 생성되고 난 발전기를 만지고 싶지 않아 추가해야합니다.

Edit2가 :

좋아, 나는 내가 그것을 작동하게하기 위해 발전기를 접촉 할 필요가 있음을 알고 있습니다. 하지만 여전히 Active Record가 Comp_id를 설정하지 않는 이유는 무엇입니까?

질문 :

가 어떻게 CompId == 아이디 있도록 액티브는 자식 클래스의 JoinedKey의 값을 설정 알 수 있나요?

[JoinedKey("comp_id")] 
public override int Id { get { return base.Id; } } 

을 ... 그리고 그들이주는 예는 잘못된 것입니다 :

답변

0

내가 사용할 필요가 있다고 생각합니다.

0

이것은 상당히 오래된 질문이지만 동일한 문제가 발생했습니다. Castle.ActiveRecord 페이지의 예가 잘못되었습니다.

[ActiveRecord("entity"), JoinedBase] 
public class Entity : ActiveRecordBase 
{ 
    ... 
    protected int id; // use protected instead of private 

    [PrimaryKey] 
    private int Id 
    { 
     get { return id; } 
     set { id = value; } 
    } 
} 

[ActiveRecord("entitycompany")] 
public class CompanyEntity : Entity 
{ 
    // private int comp_id; // this member variable is not required 

    [JoinedKey("comp_id")] 
    public int CompId 
    { 
     get { return id; } // access the member variable of the base class 
     set { id = value; } // access the member variable of the base class 
    } 
    .... 
} 

난 그냥 성공적으로 내 유형 계층 구조로 테스트했습니다

는이 같은 문제 (주석 수정하여 코드 예제를) 해결할 수 있습니다.

관련 문제