PrefetchPath For two Forieng Keys from Same Table

Posts   
 
    
Posts: 3
Joined: 14-May-2010
# Posted on: 14-May-2010 09:44:28   

Hello Everybody, I have two tables. Conditions and Data. Conditions table has two foriegn keys from Data table i.e. LeftDataId And RightDataId. And Data table has DataId And Value fields.

Now I want to populate my control with data against LeftDataId And RightDataId which can be different and can be same, for this I have made a class 'ConditionsEntity' in which I want to get 'this.Data.Value' for LeftDataId and RightDataId.

Can Anyone tell me, how can I get Data Value against LeftDataId and RightDataId.

Thanks in Advance.

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 14-May-2010 11:09:47   

In the LLBLGen Designer, go to the "Edit Properties" of the Conditions Entity. In the "Fields on relations" tab, you will find both of the fields mapped to these relations. These are the entity objects representing related Data Entity, attached using each of the FKs.

It is recommended that you rename these fields to recognize them easily in the code. So instead of Data and Data_ (as they might be created by default), you can rename them to LeftData and RightData.

Save the project and re-generate the code.

Now you should have 2 recognizable prefetchPath properties, something like: PrefetchPathLeftData & PrefetchPathRightData.

So now you can use both of these prefetchPaths to prefetch both of the entities when you fetch the Condition Entity.

Posts: 3
Joined: 14-May-2010
# Posted on: 14-May-2010 11:28:00   

Hello Walaa, I have declared prefetchPath.Add(Conditions.PrefetchPathData) and prefetchPath.Add(Conditions.PrefetchPathData). But in ConditionEntity, Data is Always null.

Please elaborate how to get it's original value.

Note: I am using Entities in Visual Studio 2010, and I can not work with Designer.

Posts: 3
Joined: 14-May-2010
# Posted on: 14-May-2010 11:33:30   

Hello Walaa, I have solved the situation. Still thank you very much for taking your time. simple_smile