Using SelfService and Target-Per-Entity
Given a simple relationship like this:
Person (NOT ABSTRACT)
------Employee
------Customer
if you have that setup using Target-Per-Entity how do you do the following:
1) Determine what kind of entity it is. If you GetMulti into a collection, to determine what kind of object it is are we just supposed to use the 'is' operator? Like:
if (myEntity is Employee)
{
(myEntity as Employee).Salary=1000;
}
2) If you have an entity of a given type, what is the best way to get it to the other type? For example, suppose you have a PersonEntity that was neither an Employee or a Customer, just a Person. They then went to work for you, so now they are an employee. What is the best way to make that Person an Employee?
Perhaps something like this? (I am just thinking there is a more elegant way)
PersonEntity person = new PersonEntity(12);
//now turn them into an employee.
EmployeeEntity employee= new EmployeeEntity();
employee.PersonPKey = person.PersonPKey;
At the database level, we just add a record to Employee table with the PKey of Person. However, unsure how to best do that with your objects.