filter ilist

Discussion in 'ASP .Net' started by jvcoach23, May 6, 2008.

  1. jvcoach23

    jvcoach23 Guest

    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, May 6, 2008
    #1
    1. Advertising

  2. jvcoach23

    Leon Mayne Guest

    "jvcoach23" <> wrote in message
    news:1lsrv3nuoqhi5.co31mzepqbt4$...
    >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)
     
    Leon Mayne, May 7, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. frank

    Implement IList Interface

    frank, Jul 11, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    569
    frank
    Jul 11, 2003
  2. DaveF

    Need to pass a method an Ilist

    DaveF, Dec 8, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    323
    Karl Seguin
    Dec 8, 2004
  3. Flip
    Replies:
    1
    Views:
    474
    Brock Allen
    Mar 28, 2005
  4. =?Utf-8?B?Tmljaw==?=
    Replies:
    6
    Views:
    25,042
    =?Utf-8?B?Tmljaw==?=
    Jul 19, 2006
  5. bruce barker
    Replies:
    1
    Views:
    448
    =?Utf-8?B?VFo=?=
    Dec 19, 2006
Loading...

Share This Page