EntityRelation question

Posts   
 
    
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 30-Jan-2007 20:22:15   

If AEntity has a 1:N relation with BEntity through AEntity.AEntity_ID : BEntity.AEntity_ID, is there a way, knowing the string "AEntity_ID" that I can know this corresponds to the BEntity.AEntity object property?

The reason I ask is that I am designing a combobox that has a FieldName property that the designer can set, and when this field is changed I want the combobox to go and fetch the correct entity and hook it into the correct property on the entity...

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 31-Jan-2007 06:52:25   

I don't understand your question. Wiould you please explain in more details?

mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 31-Jan-2007 16:24:49   

Walaa wrote:

I don't understand your question. Wiould you please explain in more details?

Sorry, that was a bit convoluted simple_smile

Given the string "Manager_ID" on the EmployeeEntity, I would like to get the string "Manager" or whatever the related property name connecting EmployeeEntity to ManagerEntity.

mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 31-Jan-2007 20:35:38   

I just tried to do it with an LPT template using the relation.UtilizingPropertyName, but that returns an incorrect answer in an entity inheritance scenario (where the related entity is part of a hierarchy)

Update: I figured out how to do it with a TDL template but this is kind of a pain because 99% of my template code is LPT...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 01-Feb-2007 10:37:15   

mikeg22 wrote:

I just tried to do it with an LPT template using the relation.UtilizingPropertyName, but that returns an incorrect answer in an entity inheritance scenario (where the related entity is part of a hierarchy)

The end entity (related entity) is always the entity to which the relation is with, so if Customer has a relation with Order, then Order is the end entity, and if Order has a subtype, that's not important, nor do you get that entity.

Though did you loop over HierarchyRelations or Relations ?

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 01-Feb-2007 17:15:03   

Otis wrote:

mikeg22 wrote:

I just tried to do it with an LPT template using the relation.UtilizingPropertyName, but that returns an incorrect answer in an entity inheritance scenario (where the related entity is part of a hierarchy)

The end entity (related entity) is always the entity to which the relation is with, so if Customer has a relation with Order, then Order is the end entity, and if Order has a subtype, that's not important, nor do you get that entity.

Though did you loop over HierarchyRelations or Relations ?

I mean if Customer has a relation with Order, Order is a subtype, and the relationship is named "Customer.TheOrder" then I need a way to translate "order_Id" in the Customer entity to the string "TheOrder". In TDL, I can get this with <[MappedFieldNameRelation]> but I can't find the equivalent in LPT. Ideally I would like to just have a way to directly query the EntityRelation object in runtime code to come up with this...

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 01-Feb-2007 18:09:15   

mikeg22 wrote:

Otis wrote:

mikeg22 wrote:

I just tried to do it with an LPT template using the relation.UtilizingPropertyName, but that returns an incorrect answer in an entity inheritance scenario (where the related entity is part of a hierarchy)

The end entity (related entity) is always the entity to which the relation is with, so if Customer has a relation with Order, then Order is the end entity, and if Order has a subtype, that's not important, nor do you get that entity.

Though did you loop over HierarchyRelations or Relations ?

I mean if Customer has a relation with Order, Order is a subtype, and the relationship is named "Customer.TheOrder" then I need a way to translate "order_Id" in the Customer entity to the string "TheOrder". In TDL, I can get this with <[MappedFieldNameRelation]> but I can't find the equivalent in LPT. Ideally I would like to just have a way to directly query the EntityRelation object in runtime code to come up with this...

That TDL statement just returns the UtilizingPropertyName of the relation. It doesn't matter if the related entity is a subtype or not, as long as entity is the end entity.

Perhaps a snippet of your lpt code would be best simple_smile (and also, if you really can't find it, there's always the TDL Interpreter sourcecode simple_smile )

Frans Bouma | Lead developer LLBLGen Pro
mikeg22
User
Posts: 411
Joined: 30-Jun-2005
# Posted on: 02-Feb-2007 21:11:52   

I'm losing it. I just checked my LPT results with my TDL results and they are identical and both correct. Sorry disappointed