Filtering while accessing object instances

  • Thread starter Thread starter Krish
  • Start date Start date
K

Krish

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
 
If you go here:

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

You can download the sample code.

Needed alterations:

1. Send the predicate/filter to the controller

private List<BusinessObjects.Customer>
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<Customer> ).


...

Then replace with your custom business objects, and instead of using an
IDataReader, use your file based way of reading and creating objects.
 
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.
 
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.

..........
 
Back
Top