Clear Filter?

Posts   
 
    
davisg avatar
davisg
User
Posts: 113
Joined: 27-Feb-2005
# Posted on: 31-Mar-2005 17:41:26   

Is there a way to clear a filter? I know you can add to it but I want to use the same filter routine throughout my form, i.e:

private IPredicateExpression filter = new PredicateExpression();

private void procedure blah1 {
filter.clear(); filter.Add(new FieldLikePredicate(EntityFieldFactory.Create(ArtistFieldIndex.Artist), "a%")); artists.GetMulti(filter,0,_artistSorter,null,pagenumber,50); }

private void procedure blah2 {
filter.clear(); filter.Add(new FieldLikePredicate(EntityFieldFactory.Create(ArtistFieldIndex.Artist), "b%")); artists.GetMulti(filter,0,_artistSorter,null,pagenumber,50); }

Geoff.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Apr-2005 11:51:59   

you could also do: filter = new PredicateExpression();

Frans Bouma | Lead developer LLBLGen Pro
davisg avatar
davisg
User
Posts: 113
Joined: 27-Feb-2005
# Posted on: 02-Apr-2005 02:01:17   

Thanks Frans smile

LloydM
User
Posts: 17
Joined: 05-Dec-2007
# Posted on: 25-Jan-2008 21:30:47   

I would also like to reuse an IPredicateExpression object, but have encountered these issues:

1) Invoking the Clear method of the IPredicateExpression object appears to have no effect as all my original parameters remain intact.

2) Setting the IPredicateExpression object to a new instance clears the parameters, but I'm unable to add new filter expression parameters. I do not receive an exception.

Code:

IPredicateExpression someFilter= new PredicateExpression(); someFilter.Add(EntityFields.SomeField== someValue); List<int> entityIndex= new List<int>();

// retrieve the collection using the filter EntityCollection.GetMulti(someFilter);

//now filter the collection within a loop based on another entity collection foreach (EntityClass childEntity in parent.childEntityCollection) { someFilter= new PredicateExpression(); //parms cleared, but can't add new ones someFilter.Clear(); //parms not cleared someFilter.Add(EntityFields.SomeField== childEntity.SomeCustomProperty);

       //should only have a single match here
       entityIndex= EntityCollection.FindMatches(someFilter);

       // get a reference to entity we just found
       Entity= EntityCollection[entityIndex[0]];

    }
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Jan-2008 02:07:51   

the .Clear method indeed clears the list disappointed Could you please be more specific in why do you think you can't add parameters after the re-instantiation?

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 26-Jan-2008 11:35:49   

ALso could you post the LLBLGen Pro version you're using?

Frans Bouma | Lead developer LLBLGen Pro
LloydM
User
Posts: 17
Joined: 05-Dec-2007
# Posted on: 01-Feb-2008 20:55:49   

David and Frans,

Sorry I took so long to respond. I'm able to re-use the filter now after invoking the Clear method, it just doesn't show the new predicates.

It appears that the Predicate base parameters collection of the Predicate Expression object isn't refreshing since it still shows the old predicate values in the .Net variable watch window.

I'm using LLBLGen Pro v.2.5 Final with the Self Servicing template group.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 02-Feb-2008 23:15:11   

Can't reproduce your error, I've tried everything, could you send us a test dummy project?