Easy way to get a list of single values?

Posts   
 
    
philippe
User
Posts: 6
Joined: 19-Nov-2004
# Posted on: 19-Nov-2004 10:15:27   

In my "old" T-SQL based application, I fill combo boxes with a list of previously used values for a certain field.

For example, I use the following query to fill a combo box:

"SELECT DISTINCT Category FROM tblCD where Category is not null ORDER BY Category"

I'm sure there's an easy way to do this in LLBLGen Pro, but I can't figure it out from the help file. And since I am lazy, I thought it would be easier to ask here simple_smile

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 20-Nov-2004 10:46:15   

Create a typed list, or in code create a dynamic list (since runtimes 1.0.2004.1, released on sep 24) simple_smile Please see the documentation of the typed list / views in the using the generated code documentation simple_smile

Frans Bouma | Lead developer LLBLGen Pro
philippe
User
Posts: 6
Joined: 19-Nov-2004
# Posted on: 22-Nov-2004 15:14:28   

Thanks. It works indeed, but it requires a lot of code to do a very simple thing.

This brings me to the following question:

Are there any plans to implement some kind of expression parser in LLBLGen Pro ? It would be nice if we could write filter or sort expressions in SQL-like syntax.

For example, instead of:

IPredicateExpression p = new PredicateExpression();

p.Add(PredicateFactory.Like(LicenseFieldIndex.Description,"%" + strSearch + "%"))
p.AddWithOr(PredicateFactory.Like(LicenseFieldIndex.LicNr,"%" + strSearch + "%");
        
return LicInternCollection.GetMultiAsDataTable ( p , 0 , 
      new SortExpression(SortClauseFactory.Create(LicenseFieldIndex.LicNr,SortOperator.Ascending))
    ) ;

We could use:

return LicInternCollection.GetMultiAsDataTable( "License.Description LIKE '%" + strSearch + "%' or License.LicNr like '%" + strSearch + "%'" , 0 , "License.LicNr ASC");

Similar constructs are possible in a number of other ORM mappers.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 22-Nov-2004 16:25:32   

an OPath parser is planned indeed which will create a predicate/relation graph behind the scenes. Keep in mind that IPredicate objects are flexible and typed, a string is not flexible (you can't add your own predicate classes) nor is it typed, so you run the risk of typo's.

Nevertheless, it can be handy to have a less verbose method of creating queries.

Frans Bouma | Lead developer LLBLGen Pro