FieldCompareExpressionPredicate doesn't work

Posts   
 
    
Ups_Weera
User
Posts: 4
Joined: 31-Oct-2006
# Posted on: 07-Nov-2006 20:58:20   

Hi

I am using v2.0, Adapter. I am trying to create a windows form that allows me to specify criteria for fetching records into a dynamic list which is bound to a datagrid. I have the following code:


EntityField2 afield = (EntityField2) employee.Fields[cbCritFields1.SelectedItem.ToString()]; 
bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(new FieldCompareExpressionPredicate(afield,null,ComparisonOperator.GreaterThan, txtValue1.Text)); 

cbCritFields1 is a combo box, that contains a list of fields

I get the following error:

Error 2 Argument '4': cannot convert from 'string' to 'SD.LLBLGen.Pro.ORMSupportClasses.IExpression'

But if I change the above code to:


EntityField2 afield = (EntityField2) employee.Fields[cbCritFields1.SelectedItem.ToString()];
bucket = new RelationPredicateBucket();
bucket.PredicateExpression.Add(afield > txtValue1.Text);

There is no problem and the results come back properly. What is the difference, and how can I make the first one work? Appreciate your response

Weera

bclubb
User
Posts: 934
Joined: 12-Feb-2004
# Posted on: 08-Nov-2006 02:47:05   

FieldCompareExpressionPredicate is used to compare expressions such as Order.Price + Order.Tax what you ware wanting to do is compare a value so you would use FieldCompareValuePredicate. This is what predicate is being generated by

bucket.PredicateExpression.Add(afield > txtValue1.Text);
Ups_Weera
User
Posts: 4
Joined: 31-Oct-2006
# Posted on: 08-Nov-2006 17:35:02   

Oh ok, Thanks, I guess then I had to use FieldCompareValuePredicate instead of FieldCompareExpressionPredicate.