I have an entity class which has 3 columns; entityType, entityID and EntityText. I want to fill entityText column from 3 conditional tables.For example: If entity type is 3(contact) and entityID is 2 it will join to Contacts table and will get the contact by entityID and set contact.name property as EntityText. How can I do this?
Details:
Not same object class.
Contact
{
contactID
firstName
lastName
..
}
Company
{
companyID
name
address
...
}
Task{
taskID
entityID
entityType
entityText= Company.name or Contact.firstName + Contact.lastName
...
}
EDIT: refactored to match the updated question
because there is logic behind the content of EntityText i would prefere polymorphism