FetchEntity using a relation

Posts   
 
    
usschad
User
Posts: 77
Joined: 11-Sep-2008
# Posted on: 27-Oct-2008 22:19:20   

I was hoping there was a way to fetch an entity using a relation.

Here are my tables with the significant columns:

Package -PackageID

PackageOption -PackageOptionID -PackageID

Contract -PackageOptionID

I'm working with a Contract which has the PackageOptionID. Is there a way that I can fetch just a PackageEntity using the PackageOptionID? FetchEntityUsingUniqueConstraint only allows a predicate expression parameter. I was looking forward to being able to pass it a RelationPredicateBucket to allow me to use a join to select my package without having to select the PackageOption and prefetch the Package.

I'm using LLBLGenPro 2.0.0.0 with the adapter template.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 28-Oct-2008 05:42:18   

Mmmm.. I think you have to fetch a EntityCollection and pass a filterpredicatebucket to the call containing the appropriate relation.

IRelationPredicateBucket filter = new RelationPredicateBucket(PackageOptionFields.PackageOptionID == someValue);
filter.Relations.Add(PackageEntity.Relations.PackageOptionEntityUsingPackageId);

EntityCollection<PackageEntity> packages = new EntityCollection<PackageEntity>();
adapter.FetchEntityColection(packages, filter);

PackageEntity thePackage = packages[0];

I know that isn't exactly what you want. But, at lest you do just one query.

David Elizondo | LLBLGen Support Team