Filters that support different entities

Posts   
 
    
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 30-Jan-2007 21:09:04   

LLBLGen v 2.0 XP PRO SP2 VS 2005 C#

We have multiple typed views that contain the same fields from related tables. Is it possible to create a generic mechanism that returns a suitable PredicateExpression regardless of the view? The redundant code that we're writing is a horrible "smell" in my opinion..

More specifically, all of our type views contain a Status property and the filters on this property are fairly complex. I want to create a function like...


public static PredicateExpression GetSpecialRecordsFilter()
{
PredicateExpression filter = new PredicateExpression();
filter.AddWithAnd(SomeTypedViewFields.Status = 'A');
filter.AddWithAnd(SomeTypedViewFields.Status = 'B');

return filter;
}

The problem is, I need to be able to use that function for other typed views and it's tightly bound to "SomeTypedViewFields".

Is this possible?

alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 31-Jan-2007 00:12:19   

Maybe one one replied because they realized I wasn't thinking clearly... derrrrr...


public PredicateExpression GetSpecialFilter(EntityField myField)
{
PredicateExpression filter = new PredicateExpression();
filter.Add(myField = "N");
filter.Add(myField = "X");
return filter;
}

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 31-Jan-2007 10:04:23   

No, you were posting in-between forum monitoring slots wink . Glad you sorted it out simple_smile

Frans Bouma | Lead developer LLBLGen Pro