그냥 두 개의 클래스를 만드는 등 :
public class Person
{
public virtual int PersonId { get; set; }
public virtual string FirstName { get; set; }
public virtual string Surname { get; set; }
}
public class Project
{
public virtual int ProjectId { get; set; }
public virtual string Title { get; set; }
public virtual Person ProjectManager { get; set; }
public virtual Person Contact { get; set; }
}
하고 사람 :)보다 더 흥미로 프로젝트에 대한 매핑 클래스
public class ProjectMap : ClassMap<Project>
{
public ProjectMap()
{
Id(x => x.ProjectId);
Map(x => x.Title);
References(x => x.ProjectManager);
References(x => x.Contact);
}
}
당신이 FNH
매핑 재정의를 사용하는 경우
public class ProjectMappingOverride : IAutoMappingOverride<Project>
{
public void Override(AutoMapping<Project> mapping)
{
mapping.Id(x => x.ProjectId); //Usually for Id I have a convention, and not define it here
mapping.Map(x => x.Title); //Also for simple properties. You could remove these lines if you have setup the conventions.
mapping.References(x => x.ProjectManager);
mapping.References(x => x.Contact);
}
}
협약에 대한 다른 구성을 잊지 마세요 :)
Aaah, 나는 참고 문헌에 대해 읽었지만 사용 방법을 잘 모르고있었습니다. 그 자리에 충돌했다! 감사! – Allov