Hard coding filters

Posts   
 
    
Ian avatar
Ian
User
Posts: 511
Joined: 01-Apr-2005
# Posted on: 13-May-2005 17:29:11   

Hi,

I've got a page which needs to show a different set of news stories depending on a parent category - News, Entertainment or Sport.

Each category entails a different filter. I want to avoid switch statements springing up within the code so I'm opting to derive a new page for each different category. At the moment there are only 3 so this isn't too big a deal.

I'm having to use inheritance because with LLBLGen, it seems one has to hard code a filter.

What would be good is if I could describe a filter user a string just like you can do with DataTable.Select.

Also, its not just as simple as passing in the categoryID as a parameter. I need to be able to add different predicates depending on the category.

Is this viable?

Ian.

Devildog74
User
Posts: 719
Joined: 04-Feb-2004
# Posted on: 13-May-2005 18:45:48   

You could leverage the strategy pattern to build a relationship predicate bucket with the appropriate predicate expressions. you could use the page as the hook to determine which strategy pattern to invoke.

I also posted a thread that is an abstract approach to building predicates. I wrote a method which uses the EntityName, FieldName, and FieldValue to build a predicate. Here is a link to that thread with the sample code:

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=738

cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 14-May-2005 23:46:54   

Ian wrote:

Hi,

I've got a page which needs to show a different set of news stories depending on a parent category - News, Entertainment or Sport.

Each category entails a different filter. I want to avoid switch statements springing up within the code so I'm opting to derive a new page for each different category. At the moment there are only 3 so this isn't too big a deal.

I'm having to use inheritance because with LLBLGen, it seems one has to hard code a filter.

What would be good is if I could describe a filter user a string just like you can do with DataTable.Select.

Also, its not just as simple as passing in the categoryID as a parameter. I need to be able to add different predicates depending on the category.

Is this viable?

Ian.

I wrote some simple templates called GlobalBuckets that would allow you to define common filters.

http://llblgen.com/tinyforum/Messages.aspx?ThreadID=2188