I have a question about FieldCompareValuePredicate. It seems that you need to use an interger literal in camparisons. When I run the following code,
public EntityCollection<ProductEntity> GetProductsWithCostAbove(int cost)
{
EntityCollection<ProductEntity> products = new EntityCollection<ProductEntity>();
IPredicateExpression predEx = new PredicateExpression();
FieldCompareValuePredicate filterElement = (FieldCompareValuePredicate)(ProductFields.StandardCost > cost);
IRelationPredicateBucket bucket = new RelationPredicateBucket();
predEx.Add(filterElement);
bucket.PredicateExpression.Add(predEx);
using (DataAccessAdapter adapter = DataAccess.AdaptorFactory.GetNewAdaptor(true))
{
adapter.FetchEntityCollection(products, bucket);
}
return products;
}
, products with a standard cost greater than the cost parameter are still included in the ResultSet.
The filter does work if I hard-code a number in there e.g. ProductFields.StandardCost > 300
Is this correct? Does it only work for hard-coded literals?