List of all the dependent entities

Posts   
 
    
Ammit
User
Posts: 59
Joined: 19-May-2006
# Posted on: 07-Jan-2008 12:19:05   

Hello,

I have to write a generic function that takes (IEntity entity) as an arguement. I want to know [before i actually make GetMulti() call] all the related Entities.

e.g. My Current Entity is A having PrimaryKey field X which is used as as FK in Entity B [Having PrimaryKey field named Y ] and in Entity C Y is used as FK.

My generic function will get object of Entity A as it is at the top of the chain.

Now I want to know the Entities Related with A , [directly or InDirectly i.e. Entity B and C]

In designer I can see EntityA to B relations. I have added an entity from "Fields on relation" section of designer and named it J

But while i code and try to get all the relations

foreach (IEntityRelation relation in entity.GetAllRelations())

in relation object i can get the name that i have given to the entity e.g. J but how can i know this J belongs to which Entity?

I expected AliasFKSide or AliasPKSide will give me name of actual entities but they have been coming as ""

Can you please let me know what is going wring in here?

thanks Ammit

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 07-Jan-2008 18:54:30   

Are you interested in meta data (e.g. 'Customer' relates to 'Order') or are you interested in the entity objects currently in the graph? (myCustomer object relates to myOrder object because myOrder.Customer == myCustomer)

Frans Bouma | Lead developer LLBLGen Pro
Ammit
User
Posts: 59
Joined: 19-May-2006
# Posted on: 07-Jan-2008 19:07:30   

Otis wrote:

Are you interested in meta data (e.g. 'Customer' relates to 'Order') or are you interested in the entity objects currently in the graph? (myCustomer object relates to myOrder object because myOrder.Customer == myCustomer)

I want to know for a master entity how many fields from different entities have been added in the "Fields on relation" tab? Currently it shows the field name and not the entity it has been mapped TO.

As an input i have the Entity object and as i want to make my routine generic i am taking IEntity as an arguement. If you have someother solution to this problem with the IEntity oobject in mind then please suggest me the same.

Once agaion thanks for your quick reply

Ammit

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 08-Jan-2008 12:48:06   

In the EntityRelation object, you have AliasEndEntity and AliasStartEntity, also you can try using GetFKFieldPeresistenceInfo() method, from which you can get the SourceObjectName of the field which can be used too if the entity names can be easily derived from the table names.

You can try the above for each EntityRelation in the entity.Relations collection. But also you should check if the relation has a mapped field or not (your requirement). using the MappedFieldName property of the relation.

Ammit
User
Posts: 59
Joined: 19-May-2006
# Posted on: 09-Jan-2008 13:42:21   

Walaa wrote:

In the EntityRelation object, you have AliasEndEntity and AliasStartEntity, also you can try using GetFKFieldPeresistenceInfo() method, from which you can get the SourceObjectName of the field which can be used too if the entity names can be easily derived from the table names.

You can try the above for each EntityRelation in the entity.Relations collection. But also you should check if the relation has a mapped field or not (your requirement). using the MappedFieldName property of the relation.

Hi Walla

Both the properties you mentioend are coming as "" [i.e.AliasEndEntity and AliasStartEntity ]

GetFKFieldPeresistenceInfo() belongs to which object i tried finding it on IEntity , as well as relarions etc... I tried looking in to Documentation but couldnt find anything with "GetFKFieldPeresistenceInfo()"

can you please throw some more light on this?

thanks Ammit

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 09-Jan-2008 15:32:07   

GetFKFieldPeresistenceInfo() belongs to which object i tried finding it on IEntity , as well as relarions etc... I tried looking in to Documentation but couldnt find anything with "GetFKFieldPeresistenceInfo()"

Check the LLBLGen Pro reference manual for the members of teh EntityRelation class.

Anyway I guess I was wrong again flushed Please check the following link (similar question): http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5394

Ammit
User
Posts: 59
Joined: 19-May-2006
# Posted on: 10-Jan-2008 05:56:43   

Walaa wrote:

GetFKFieldPeresistenceInfo() belongs to which object i tried finding it on IEntity , as well as relarions etc... I tried looking in to Documentation but couldnt find anything with "GetFKFieldPeresistenceInfo()"

Check the LLBLGen Pro reference manual for the members of teh EntityRelation class.

Anyway I guess I was wrong again flushed Please check the following link (similar question): http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=5394

Thats fine simple_smile

By now I already made some changes in design which avoides this situaton for now .. will keep this in mind for future use though.

thanks for your help and time