문제

직원이 널 부서를 갖도록하는 대신 'issigneddepartment'객체를 갖고 싶습니다.

public class UnassignedDepartment : Department
{
    public UnassignedDepartment() : base("not yet assigned") {
        Id = -99; <-- just some Id that can be held constant, not be generated..
    }
}

이것은 부서 수업의 정적 편의 필드에서 액세스 할 수 있습니다.

public class Department : Entity
{
    public static readonly Department UNASSIGNED = new UnassignedDepartment();

    ....    
} 

FNH Automapping, Overrides & Conventions가 혼합되어 S#rparch의 프레임 워크를 기본 엔티티로 사용하고 있습니다. 끈기있는 관점에서, '특별한'ID를 가진 다른 부서와 이것을 유지하는 것은 논리적으로 보이지만, 그 방법을 제대로 수행하는 방법을 모르겠습니다. 저를 깨달으십시오!

thx, 베리

도움이 되었습니까?

해결책

나는 당신이 성취하려는 것을 이해하지 못하지만 아마도 이것이 도움이 될 것입니다. 직원의 개인 분야로서 부서를 맵핑하고 널이없는 경우 부호없는 부과를 반환합니다.

private Department _department; // map this in FNH

public Department Department
{
    get { return _department ?? _department.UNASSIGNED; }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top