filter ilist

  • Thread starter Thread starter jvcoach23
  • Start date Start date
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
 
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)
 
Back
Top