collection filter

Posts   
 
    
hootie
User
Posts: 6
Joined: 24-Aug-2006
# Posted on: 22-Nov-2006 12:50:09   

when work with a collection I often want to filter out the result on a specific parameter in the entyties. an example without filter:


repeater1.datasource = currentUser.ForumThreadsCollectionViaMyThreads

this works just fine. but if I want a filter on for example Mythreads.isFavourite = true I have to use the getMulti method. correct? an example with filter:

dim filter blablabla
currentUser.ForumThreadsCollectionViaMyThreads.getMulti(filter)
repeater1.datasource = currentUser.ForumThreadsCollectionViaMyThreads

Is there an easier way of doing this?

Now, if this is the only way. I have another problem. when I use this way of filtering. the relation between, in this case currentUser and MyThreads gets lost... I then have to add myThreads.user = currentUser to my filter...

jbb avatar
jbb
User
Posts: 267
Joined: 29-Nov-2005
# Posted on: 22-Nov-2006 14:24:02   

Hello,

If you already have your entity collection you could use the FindMatches method instead of getMulti that will give you the list of index of your collection and after you can make your own collection without remade all the relations.


Dim filter As new FieldCompareValuePredicate(.....)
Dim indexes As ArrayList = currentUser.ForumThreadsCollectionViaMyThreads.FindMatches(filter)