Subpath question

Posts   
 
    
edalzell
User
Posts: 44
Joined: 27-May-2008
# Posted on: 28-Aug-2008 22:58:51   

I just know this can be done with LLBLGen generated code, but I must be having a slow brain day, as I can't figure it out.

I have a table with 3 columns: ID, ParentFormID, RelatedFormID and a Form table (RelatedFormId is the PK data in Form)

I want to get an EntityCollection<FormEntity> of all related forms based on a parentFOrmID.

Any advice?

Thanks

edalzell
User
Posts: 44
Joined: 27-May-2008
# Posted on: 28-Aug-2008 23:23:45   

This is what I want, but I don't think it will work:

        EntityCollection<FormEntity> forms = new EntityCollection<FormEntity>();

        IRelationPredicateBucket bucket = new RelationPredicateBucket(RelatedFormFields.ParentFormId == formId);

        adapter.FetchEntityCollection(forms, bucket);
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Aug-2008 05:45:35   

I don't get what is your table structure. I suspect it's like this:

SomeTable ID PK ParentFormID RelatedFormID (FK to Form)

Form RelatedFormID PK ...

And you want to obtain all Form's records filtered on some ParentFormID. Is that correct?

David Elizondo | LLBLGen Support Team
edalzell
User
Posts: 44
Joined: 27-May-2008
# Posted on: 29-Aug-2008 17:56:25   

Yes, you have my table structure correct.

What I want, is given a parent form id, get a collection of FormEntity that contains all of the related forms.

I understand I can do this manually (get the RelatedForm collection then loop through and pull out the Form), but I was hoping for a cleaner way.

Thanks

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Aug-2008 20:42:25   

Ok. Then you could use FieldCompareSetPredicate:

// build the predicate
IRelationPredicateBucket bucket = new RelationPredicateBucket();

FieldCompareSetPredicate subQueryFilter = new FieldCompareSetPredicate(
     FormFields.RelatedFormId, null, SomeTableFields.RelatedFormId, null,
     SetOperator.In, (SomeTableFields.ParentFormId == someValue ));

bucket.PredicateExpression.Add(subQueryFilter);

// fetch results
EntityCollection<FormEntity> forms = new EntityCollection<FromEntity>();
using (DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchEntityCollection(forms, bucket);
}
David Elizondo | LLBLGen Support Team