質問

従業員に部署を空欄にする代わりに、「UnassignedDepartment」オブジェクトを作成したい:

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

Departmentクラスの静的な便利なフィールドからアクセスできます:

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

    ....    
} 

ベースエンティティとしてS#rpArchのフレームワークを使用し、FNH自動マッピング、オーバーライド、および&amp;慣習。永続性の観点から、これを「特別な」IDで他の部門に保持することは論理的に思えますが、適切に行う方法はわかりません。教えてください!

Thx、ベリル

役に立ちましたか?

解決

私はあなたが何を達成しようとしているのか理解できませんが、おそらくこれが役立つでしょう。 DepartmentをEmployeeのプライベートフィールドとしてマップし、nullの場合UnassignedDepartmentを返します。

private Department _department; // map this in FNH

public Department Department
{
    get { return _department ?? _department.UNASSIGNED; }
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top