Filtering while accessing object instances

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krish

    #1

    Filtering while accessing object instances

    Hi All,
    I have a component that reads a file and returns the data as a an
    array of objects. Now I want to add the capability of filtering on
    this.

    This means if an array of objects is returned I should be able to
    specify
    give me objects where name starts with "A" or something of that sort.

    Without loopong through the instances returned can I some how do a
    filtering? There is no DB involved hence we cannot have a query with a
    where clause.

    Any helps to this will be appretiated.

    Kris

  • sloan

    #2
    Re: Filtering while accessing object instances


    If you go here:

    http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!140.entry

    You can download the sample code.

    Needed alterations:

    1. Send the predicate/filter to the controller

    private List<BusinessOb jects.Customer>
    SerializeCustom ers(IDataReader dataReader, bool deep , CustomerFilter
    filter )
    {

    }

    and in that method, as each item is created (Customer), do a check to see if
    there is a match... and then decided to add it or not to add it to the
    CustomerCollect ion ( List<Customer).


    ...

    Then replace with your custom business objects, and instead of using an
    IDataReader, use your file based way of reading and creating objects.





    "Krish" <balacr@gmail.c omwrote in message
    news:1194265881 .656609.89340@z 9g2000hsf.googl egroups.com...
    Hi All,
    I have a component that reads a file and returns the data as a an
    array of objects. Now I want to add the capability of filtering on
    this.
    >
    This means if an array of objects is returned I should be able to
    specify
    give me objects where name starts with "A" or something of that sort.
    >
    Without loopong through the instances returned can I some how do a
    filtering? There is no DB involved hence we cannot have a query with a
    where clause.
    >
    Any helps to this will be appretiated.
    >
    Kris
    >

    Comment

    • Krish

      #3
      Re: Filtering while accessing object instances

      In my case it is not a Select string that I need to construct.
      I need to filter object instances. So the logic is getting very
      complicated when there is an OR condition involved.

      Comment

      • sloan

        #4
        Re: Filtering while accessing object instances

        You're right. Or's don't play nice.

        I guess you can send in a collection (or array) of CustomerFilter' s, and do
        the whole..loop until true trick, else false.

        ..........



        "Krish" <balacr@gmail.c omwrote in message
        news:1194349985 .737872.313630@ k79g2000hse.goo glegroups.com.. .
        In my case it is not a Select string that I need to construct.
        I need to filter object instances. So the logic is getting very
        complicated when there is an OR condition involved.
        >

        Comment

        Working...