using relations at EntityCollection

Posts   
 
    
PAZIMLI
User
Posts: 82
Joined: 01-May-2008
# Posted on: 01-May-2008 16:50:49   

Is anyone know How can I use relations at EntityCollection.(Et1) For example:

I use Table Customer consists of fields -CustomerNumber -CustomerName -CityCode

An other Table named City Fields are -CityCode -CityName

When I fetch Et1, I want to see CityName also.I only change(add,delete,update) CustomerTable,CityTable dont change.disappointed

How can I fetch records like that?

thanks PINAR

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 08-May-2008 15:30:24   

Using a PreftechPath you should be able to fetch Customer.City entity as well.

Please refer to the manual's section: Using the generated code -> Adapter/SelfServicing -> Prefetch paths.

And if you want you may use the Designer to add a "field on related field" to map the cityName into the Customer table.

PAZIMLI
User
Posts: 82
Joined: 01-May-2008
# Posted on: 09-Oct-2008 09:25:02   

Please give me a simple example.

Walaa avatar
Walaa
Support Team
Posts: 14946
Joined: 21-Aug-2005
# Posted on: 09-Oct-2008 11:31:08   

In the Designer to add a field mapped on a related field, please check this link

And in code you should use prefetchPath as follows:

EntityCollection<CustomerEntity> customers = new EntityCollection<CustomerEntity>();

PrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.CustomerEntity);
prefetchPath.Add(CustomerEntity.PrefetchPathCity);

DataAccessAdapter adapter = new DataAccessAdapter();
adapter.FetchEntityCollection(customers, null, prefetchPath);