2009-07-11 2 views
0

FluentNHibernate를 사용하고 있지만 NHibernate XML은 사용합니다. NHibernate가 클래스 인 프라퍼티를 가진 모델을 가지고 있습니다.

내가

public User 
{ 
    public User() 
    { 
     ProfilePicture = new Picture(); 
    } 
    public Guid Id { get; private set; } 
    public Picture ProfilePicture { get; set; } 
} 

public Picture 
{ 
    int width; 
    int height; 
} 

가 어떻게 NHibernate에 어떻게 저장하고 ProfilePicture을 PIN이하는 말할까요이 모델을 말해봐?

나는 유창함 년 같은

Map(x => x.ProfilePicture); 

하지만 나던 일을 알고있다. 사용자 및 ProfilePicture 두 개의 서로 다른 테이블에서 오는 경우

답변

2

다음 References 사용해야합니다

References(x => x.ProfilePicture); 

당신이 그것의 열 이름을 지정해야하는 경우 (예를 들어)

References(x => x.ProfilePicture, "ProfilePictureId"); 

여러 가지 다른 예가있다 documentation의 다양한 사용 사례에 대해 ProfilePicture은 사용자 테이블에 저장되어있는 경우

다음은 Component로 매핑하는 것입니다 : 내가 구성 요소를 사용됩니다

Component(x => x.ProfilePicture, c => 
    { 
     c.Map(x => x.width); 
     c.Map(x => x.height); 
    }); 
+0

. 명명 규칙을 어떻게 알 수 있습니까? –

+0

Fluent NHibernate는 기본 명명 규칙을 가졌으며, 직접 명명 규칙을 지정할 수도 있습니다. 개인적으로, 필자는 규칙을 사용하는 대신 모든 속성 등을 매핑하는 것을 선호합니다. 여기에 의사가 있습니다. 규칙 : http://wiki.fluentnhibernate.org/show/StandardMappingConventions –