EntityCollection related entities for DataSource need help

Posts   
 
    
h8ciz
User
Posts: 1
Joined: 19-Oct-2006
# Posted on: 19-Oct-2006 15:13:57   

Hi, I’m beginning in LLBLGen V2. I’m using Adapter. I have three tables :

[TPerson] ID, FirstName, LastName, AddressID, LanguageID

[TLanguage] ID, Name

[TAddress] ID, Country

so :


DataAccessAdapter adapter = new DataAccessAdapter();
EntityCollection PersonCollection = new EntityCollection(new PersonCollectionEntityFactory());
//create prefetchPath 
IPrefetchPath2 prefetchPath = new PrefetchPath2((int)EntityType.TPersonEntity);
prefetchPath.Add(TRelancesEntity.PrefetchPathTLanguage);
prefetchPath.Add(TRelancesEntity.PrefetchPathTAddress);

//create bucketFilter
RelationPredicateBucket bucketFilter = new RelationPredicateBucket();
bucketFilter.PredicateExpression.AddWithOr(TPersonFields.FirstName== "toto");
            

adapter.FetchEntityCollection(PersonCollection , bucketFilter, prefetchPath);

gridControl1.DataSource = PersonCollection;


My gridControl display just Person fields but i want to display all fields (TLanguage and TAddress fields)

Thanks you help simple_smile hc

jaschag
User
Posts: 79
Joined: 19-Apr-2006
# Posted on: 19-Oct-2006 15:38:15   

You need to add the fields you want to see in the grid as "fields mapped on related fields" in your TPerson class (in the LL...) designer. I.e. Add language name and country.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 19-Oct-2006 15:55:16   

Jaschag is correct. And wth the help of those PrefetchPaths (the ones you have used), those fields get loaded with data.