mshe wrote:
Hello,
I'm using the inheritence features in LLBLGen Pro 2.0 using TargetPerEntity (1 entity per table).
I have a table called BaseObject and another table called ChildObject.
ChildObject inherits from BaseObject.
Given a set of PKs, how can I return an entitycollection which contains ChildObjects + BaseObjects?
For example, if my data is like:
1 - Base object
2 - ChildObject
3 - Base Object
4 - Base Object
and I pass in a set of keys: 2,3, I should get back an entityCollection with:
2 - ChildObject
3 - Base Object
If I put a filter on the BaseObject table, will LLBLGen automatically query child tables to determine the type of the object - or will it just assume the object is a "BaseObject" unless I explicitly query the child tables?
Thanks.
It will do the polymorphic fetching for you. If you fetch a collection of BaseObject instances, with the filter for 2 and 3, it will fetch 2 and 3 into an instance of the class type they represent, and as ChildObject is-a BaseObject, it will be loaded and you'll get in your collection a ChildObject (2) and a BaseObject (3).
If you fetch a childobject collection (I assume you're using adapter so you have set the factory to ChildObjectEntityFactory), llblgen pro knows which tables to fetch the data from, and as childobject is a subtype, it will only fetch entities of type childobject and subtypes of childobject.