This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi guys, How would I configure a Query object and its QueryExpression to do this: (Field1 == Param1) && (Field2 == Param2 || Field2 == Param3) I tried: query.QueryExpression &= Entity.Attribute("Field1") == Param1; query.QueryExpression &= Entity.Attribute("Field2") == Param2 || Entity.Attribute("Field2") == Param3; Cheers Joseph |
|
|
Try: var rhs = Entity.Attribute("Field2") == Param2 || Entity.Attribute("Field2") == Param3; query.QueryExpression = Entity.Attribute("Field1") == Param1 && rhs;
Jeremy |
|
|
Thanks Jeremy, that works fine. Would it be correct to assume a QueryExpression represents parentheses, and it can be used to define precedence? |
|
|
Yes, that is a correct assumption. Parentheses also represent parentheses (or, rather, force the C# compiler to construct the QueryExpressions in the desired grouping), so you can also write: Entity.Attribute("Age") > 10 && (note parentheses around the || clause). This should also work with &=, so if you add parentheses to your original code you should be good to go without needing to introduce the rhs temp variable. |
|
|
Thanks!! :) |
|