Wrapper Classes

Posts   
 
    
esmith
User
Posts: 3
Joined: 27-Sep-2005
# Posted on: 31-Oct-2005 17:51:03   

Has anyone attempted to write wrapper classes for common LLBLGen functions such as applying filters, joins and sorts dynamically?

For example, one may want to have helper functions that return Collections of Entity Objects based on parameters passed in. The help function could disect the information passed in, apply filters as neccessary and return different types of object collections based on what was requested.

This would allow developers to easily call the helper functions without having to create the precdicate filters for each type of scenario we run into where we want data in a different manner.

One problem I ran into was determining how to dynamically pass the ObjectField.PropertyFieldIndex to the Predicate Factory Methods such as "CompareValue()" because the predicate factory uses an overloaded method for each tables enumerated field indexes.

One work around would be to have the help function accept the table name and the field names you want to filter on then perform a switch statement. However that would require writing a case statement for every table, field combination. Or atleast writing them for the commonly used fields which is still a lot.

If anyone has tried similar ideas or has any suggestions I would love to hear/see them.

Thanks,

Eric

beekde
User
Posts: 14
Joined: 08-Jul-2005
# Posted on: 05-Nov-2005 01:24:35   

One problem I ran into was determining how to dynamically pass the ObjectField.PropertyFieldIndex to the Predicate Factory Methods such as "CompareValue()" because the predicate factory uses an overloaded method for each tables enumerated field indexes.

I ran into this as well. pretty much ended up with a gigantic switch statement and some logic around mapping my field name to my entity using some reflection techniques.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 05-Nov-2005 12:00:28   

You can instantiate an enum using System.Enum and its static methods.

Another way to work with this is to use Entityfield(2) objects and teh Field*Predicate classes directly, bypassing the Predicatefactory. As these are helper methods, you write the code once anyway.

Frans Bouma | Lead developer LLBLGen Pro
cmartinbot
User
Posts: 147
Joined: 08-Jan-2004
# Posted on: 05-Nov-2005 22:05:27   

I wrote the Global Buckets templates back in January of this year that you could use to define your predicates and relations......ehhh...globally wink Have a look in the template SVN repository. You still have to write them once though.