Hi,
I am struggling a bit trying to compare an expression to a constant value, as in the following SQL query:
SELECT *
FROM property p
INNER JOIN currency c ON c.ID = p.CurrencyID
WHERE (p.Price / c.ExRate) > 1000
I have tried the following (adapted from the manual, and a bit of a stab in the dark..) but it doesn't work:
IExpression leftOperand = new Expression(PropertyFields.Price, ExOp.Div, CurrencyFields.ExRate);
IExpression rightOperand = new Expression(1000, ExOp.None, (IEntityFieldCore)null);
IEntityField2 field = PropertyFields.Price.SetExpression(leftOperand);
IPredicate priceFilter = new FieldCompareExpressionPredicate(field, null, ComparisonOperator.GreaterEqual, rightOperand);
filter.PredicateExpression.Add(priceFilter);
Searching the forums, I thought I'd found my answer in:
http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=8765
...but the suggestion given there won't compile:
IPredicate filter = ((PropertyFields.Price / CurrencyFields.ExRate) > 1000);
The compiler says "Operator '>' cannot be applied to operands of type 'SD.LLBLGen.Pro.ORMSupportClasses.Expression' and 'int'"
I feel like I'm missing something obvious here but whatever combination of expression and field objects I combine I can't quite get it. If anybody knows how to do this I'd be most grateful!
I'm using 2.6 Final, adapter, .NET 3.5, MySql 5.0
Thanks in advance,
Dan