PredicateExpression.TryParse

Posts   
 
    
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 16-Dec-2006 20:16:59   

In a future version, I would like to see a string to predicate expression parser. I could be used to make using EntityCollectionViews work easier with things that work with dataviews.

This would take a dataview filter string and convert it to a predicated expression For example "[Amount] >= 15.26"

A similar capability to convert sort strings to sort expressions would also be handy.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 16-Dec-2006 20:28:11   

I don't think that's worth the effort. First of all, we'll have Linq sooner or later, and second of all, we've the operator overloading + field factories. So it's not really necessary to parse strings, also because these are parsed at runtime, so error prone.

Do you have any particular special case in mind where this system is better than what's available?

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 17-Dec-2006 13:30:52   

Do you have any particular special case in mind where this system is better than what's available?

I have a couple of thoughts. 1) I have code that works with data tables, in many ways I can easily replace the datatable with an entitycollection<T>. However in places I am performing sorting and filtering on the datatable I need to change from a filter string to a predicate expression or sort string to a sort expression. This feature would allow me to convert one of these strings to the corresponding expression. By providing this you would make it easier to "plug in" LlblGenPro. It is a similar idea to making excel read 123 formats, back in the day when 123 was king. Ease of migration.

2) Predicate expressions aren't serializable for web services, this would give an string based way to pass them around.

3) 3rd party grids (I use component one's) have extensive built in support for user based, client side filtering. There are a few spot's though, where the filter related events are providing information formated as a datatable filter/sort string. This would allow me to plug into their system without me having to replace their filter builder with a custom predicate expression builder.

Chester
Support Team
Posts: 223
Joined: 15-Jul-2005
# Posted on: 17-Dec-2006 19:12:02   

You should look at the various interfaces that the LLBLGen collection types implement. IBindingList is one of them I believe, and there are others as well if not this one, which support sorting by string values.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 18-Dec-2006 11:16:30   

While I understand your points, the issue is pretty complex. You see: the addition will contain a full blown string query parser which emits llblgen pro predicate objects. This isn't that easy, for example the HQL parser in Hibernate is pretty complex as well.

The [field]=value kind of expressions are pretty easy. The (([Field] + ([Field2]*[Field3])-10)) > [Field4] is already harder to do: it asks for a full expression tree evaluation. Evaluating such a tree isn't straight forward but doable, building such a tree is another ballgame, especially because there's no real end to what you can put in an expression.

Frans Bouma | Lead developer LLBLGen Pro
arschr
User
Posts: 894
Joined: 14-Dec-2003
# Posted on: 18-Dec-2006 12:57:41   

While I understand your points, the issue is pretty complex.

Yes, it is. Just wanted to get it on your "list" for possible things to look at for future enhancements.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39927
Joined: 17-Aug-2003
# Posted on: 18-Dec-2006 18:29:58   

I'll add it to 'the list' but I'm not sure if it will ever see the light of day.

Frans Bouma | Lead developer LLBLGen Pro