PredicateExpression

Posts   
 
    
Posts: 54
Joined: 22-Jun-2010
# Posted on: 16-Jul-2010 14:23:43   

Hi,

I am using LLBLGEN 3.0 with Oracle and LLBLGen Runtime Framework.

I am trying to load the combobox with following query.

SELECT DISTINCT DESCRIPTION FROM TAXGROUP WHERE FLAG=0 ORDER BY DESCRIPTION ASC";

LLBLGEN Code I have written is

 var taxgroupdatasource = new EntityCollection<TaxgroupEntity>(new TaxgroupEntityFactory());
            var taxgroupbucket = new RelationPredicateBucket();

            using (var adaptercounty = new DataAccessAdapter())
            {
                adaptercounty.FetchEntityCollection(entityCollectiontaxgroup, null);

                taxgroupbucket.PredicateExpression.Add(TaxgroupFields.Flag == 0);
                taxgroupbucket.PredicateExpression.AddWithAnd(
                    new FieldCompareSetPredicate(TaxgroupFields.Description.SetAggregateFunction(AggregateFunction.Max)));

                adaptercounty.FetchEntityCollection(taxgroupdatasource, taxgroupbucket, 0,
                                                    new SortExpression(TaxgroupFields.Description |
                                                                       SortOperator.Ascending));
                cmbsubscriptionamounttaxgroupid.DataSource = taxgroupdatasource;
                cmbsubscriptionamounttaxgroupid.DisplayMember = "DESCRIPTION";
                cmbsubscriptionamounttaxgroupid.ValueMember = "TAXGROUPID";
                cmbsubscriptionamounttaxgroupid.SelectedIndex = -1;
            }

Problem is the line taxgroupbucket.PredicateExpression.AddWithAnd( new FieldCompareSetPredicate(TaxgroupFields.Description.SetAggregateFunction(AggregateFunction.Max))); is not supported in above function i have written. I dont know what is wrong in the line I have written or there is different of writing the same.

Option2 Is there way to bind typedview to datasource?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 17-Jul-2010 03:11:40   

Hi yoguesh,

That line of code is the only thing wrong in your code snippet. FieldCompareSetPredicate is used to create filters like:

SELECT ...
WHERE SomeColumn IN
     (SELECT SomeColumn 
       FROM AnotherTable
       WHERE ...)

Your desire Sql only has this filter:

WHERE FLAG=0 

and you already wrote that expression:

 taxgroupbucket.PredicateExpression.Add(TaxgroupFields.Flag == 0);

So, that weird code line should be removed, besides you are not passing all necessaries parameters to the constructor.

Another line that looks like unnecessary is this:

adaptercounty.FetchEntityCollection(entityCollectiontaxgroup, null);

Hope helpful wink

David Elizondo | LLBLGen Support Team