Hi there
I have two tables that store somewhat generic data which is interpreted at runtime. Lets call one "PropertyBag", the other "Property". A property bag consists of various properties which are basically key-value pairs, e.g:
PropertyBag Type=PersonInfo
PropertyKey: FirstName | PropertyValue: John
PropertyKey: LastName | PropertyValue: Doe
PropertyKey: BirthDate| PropertyValue: 1968.01.01
PropertyBag Type=MarriageInfo
PropertyKey: MarriageDate | PropertyValue: 2007.01.01
PropertyKey: DivorceDate | PropertyValue: NULL
Other entites (e.g. a User) can have various property bags of various types (e.g. several _AddressInfo _property bags that contain properties like street and city names). When mapped to code, my property bags are _PropertyBagEntity _ instances that provide a bunch of _PropertyEntity _instances. However, I'd like to work with classes like _PersonInfo _or _MarriageInfo _that derive from _PropertyBagEntity _(rather than wrapping it) in order to provide convenience properties, validation etc.
In order to do that, I need LLBLGen to dynamically instantiate the correct class types (based on a given field value that provides a flag) when performing a fetch:
//returns an instance of type PropertyBagEntity
switch(myAttributeType)
{
case AttributeType.PersonInfo:
return new PersonInfo();
case AttributeType.MarriageInfo:
return new MarriageInfo();
default:
//fall back to generic base class
return new PropertyBagEntity();
}
Is this possible and if yes, what's the recommended approach to inject this builder logic?
Thanks for your advice
Philipp