I'd like to have an 'UnassignedDepartment' object instead of letting employees have a null Department:
public class UnassignedDepartment : Department
{
public UnassignedDepartment() : base("not yet assigned") {
Id = -99; <-- just some Id that can be held constant, not be generated..
}
}
This is accessible by a static convenience field in the Department class:
public class Department : Entity
{
public static readonly Department UNASSIGNED = new UnassignedDepartment();
....
}
I'm using S#rpArch's framework as the base Entity, with a mix of FNH automapping, overrides & conventions. From a persistence standpoint, it seems logical to keep this with the other Departments with a 'special' Id, but I don't know how to do that properly. Please enlighten me!
Thx, Berryl
I don't understand what you're trying to accomplish but maybe this will help. Map Department as a private field in Employee and return UnassignedDepartment if it's null.
private Department _department; // map this in FNH
public Department Department
{
get { return _department ?? _department.UNASSIGNED; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With