Fastest way to determine type of an Entity

Posts   
 
   
 
Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 18-Mar-2008 13:35:27   

I have a hierarchy setup as follows:

Product <- SubProductA Product <- SubProductB

Is there any way I can determine the type of a product using the productId without actually completely loading the entity?

Cheers,

Peter

luciusism
User
Posts: 119
Joined: 02-Jun-2007
# Posted on: 19-Mar-2008 01:10:56   

Assuming you've already fetched the product entity and trying to get subProduct entity Type:

are we talking M:N or M:1 relationship? If the former, I'd think you could prefetch the relationship table (subProductsInProducts tbl) and include a productType column. (Which I'll assume you will use as a discriminator for your sub Types)

If the latter, then I guess you could place the productType column onto the product table.

Could you perhaps explain in more detail what you are looking to do?

Thanks,

luciusism
User
Posts: 119
Joined: 02-Jun-2007
# Posted on: 19-Mar-2008 01:14:08   

If you are talking about getting the entity type w/o ANY fetch (such as id passed via url param), then you could represent the type information in the id itself. Such as:

byte (entity type) + entity id

And the called page will have to translate.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Mar-2008 09:00:57   

Product <- SubProductA Product <- SubProductB

Are these inheritance relations? which inheritance type?

If you have the id only and no entity is loaded, then you can't determine the type unless accessing the database. Unless the id is well formatted to implecitly include the type simple_smile

Anonymous
User
Posts: 0
Joined: 11-Nov-2006
# Posted on: 21-Mar-2008 19:13:07   

Hi Walaa.

Just a quick follow up on this - does the adapter.FetchEntity method perform polymorphic fetches?

Cheers

Pete

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 22-Mar-2008 07:09:57   

Hi Pete,

This is how Polymorphic Fetches works: LLBLGenPro Help - Using the generated code - Adapter - Using the entity classes - Polymorphic fetches

David Elizondo | LLBLGen Support Team