Filtering while accessing object instances

Filtering while accessing object instances

am 05.11.2007 13:31:21 von SQLGuy

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

Re: Filtering while accessing object instances

am 05.11.2007 13:59:28 von sloan

If you go here:

http://sholliday.spaces.live.com/Blog/cns!A68482B9628A842A!1 40.entry

You can download the sample code.

Needed alterations:

1. Send the predicate/filter to the controller

private List
SerializeCustomers(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
CustomerCollection ( List ).


...

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





"Krish" wrote in message
news:1194265881.656609.89340@z9g2000hsf.googlegroups.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
>

Re: Filtering while accessing object instances

am 06.11.2007 12:53:05 von SQLGuy

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.

Re: Filtering while accessing object instances

am 06.11.2007 14:24:58 von sloan

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" wrote in message
news:1194349985.737872.313630@k79g2000hse.googlegroups.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.
>