filter ilist

J

jvcoach23

I have a custom class QBank with a public property called QBankID. I
populate the ilist(to QBank). when the iList is populated, is there a way
i can filter on the QBankID property for where it = x.

I could filter this in the database call.. but i'd like to bring back a
larger dataset and only make one call to the database for the data
retrieval, then in code filter for the id i want, work on that.. and than
filter for another id and so on. i'm just trying to limit my db calls. I
could loop through the iList to get the value, just wondering if there is a
better way..

thanks
shannon
 
L

Leon Mayne

jvcoach23 said:
I have a custom class QBank with a public property called QBankID. I
populate the ilist(to QBank). when the iList is populated, is there a way
i can filter on the QBankID property for where it = x.

I could filter this in the database call.. but i'd like to bring back a
larger dataset and only make one call to the database for the data
retrieval, then in code filter for the id i want, work on that.. and than
filter for another id and so on. i'm just trying to limit my db calls. I
could loop through the iList to get the value, just wondering if there is
a
better way..

Not that I know of. As you mentioned, it's probably best to make a function
that will loop through the collection and return a new collection containing
only the items that match the search criteria. As you're only hitting the
database once and only making the one call to the function once per block it
probably won't slow things down much.

If you want it to look fancy you could extend Generic.List with a new method
which filters out the non-matching records?

Dim colMyList as QBankList = DatabaseFunctionToRetrieveItems()
colMyList.Filter(intQBankID)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top