How to set the relation between EntityCollections

Posts   
 
    
Giri
User
Posts: 1
Joined: 15-Mar-2006
# Posted on: 15-Mar-2006 13:33:48   

Hi all

We are using thrid party control grid for our application. That grid will be populated using "EntityCollection1". One of the fields In this collection is "EarningTypeId". This field should be shown in dropdownlist. Master for this field is in "EntityCollection2". While fetching "EntittCollection1" we have to make relation for that field. So that "EarningDescription" from "EntityCollection2" will be filled in the dropdown inside grid.

Sample code: (This code is written in Rule.cs)

EntityCollection contarctBonusList = new EntityCollection(new Msgl.RO.BL.Facades.Factories.RoContractsBonusesEntityFactory()); EntityCollection EarningTypeList = new EntityCollection(new Msgl.RO.BL.Facades.Factories.RoEarningsTypesEntityFactory());

mDataAdaper.FetchEntityCollection(contarctBonusList);

How to set relation for entity collections i.e. contarctBonusList.EarningTypeId = EarningTypeList.EarningTypeId. EarningTypeDescription from EarningTypeList should be filled in dropdownlist.

Thanks & Regards

GiriBabu

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 15-Mar-2006 14:28:44   

The relation between RoContractsBonusesEntity & RoEarningsTypesEntity seems like 1:m relation (RoContractsBonusesEntity.EarningTypeId = RoEarningsTypesEntity.Id)

So there 2 cases here:

Case #1: You want to display a ReadOnly datagrid with RoContractsBonusesEntity records and showing the Description field from the RoEarningsTypesEntity table

For this case it's best that you create a field mapped on related field from the designer, thus adding the extra Description field to the RoContractsBonusesEntity, and you can display it normally like anyother field

Case #2 (which seems to be your case): You want a datagrid with RoContractsBonusesEntity records allowing the EarningTypeId to be changed according to selection from a combo box that hold Descriptions from the RoEarningsTypesEntity.

For that you should load your combo from a collection of RoEarningsTypesEntity, and you should handle decide whether to handle the selection changed at once or wait till the user saves all his changes (my favorite scenario), when you will map the selected value to the RoContractsBonusesEntity.EarningTypeId.