Trey Balut
Trey Balut

Reputation: 1395

Create correct Criteria Operator

Trying to create a Criteria.Parse operator when I have to convert the string field to an Int. Operation fails at the follwing:

Message=Parser error at line 0, character 15: syntax error; ("Convert.ToInt16{FAILED HERE}(awayML)>130")

Here is my code:

XPCollection collection = new XPCollection(session1, typeof(TodaysGame), CriteriaOperator.Parse("Convert.ToInt16(awayML)>130"));
int ct = collection.Count;

How do I form the Criteria using the Convert.ToInt16 function?

Upvotes: 1

Views: 1296

Answers (2)

nativehuman
nativehuman

Reputation: 117

The correct way to build a Criteria like that would be:

CriteriaOperator.Parse("ToInt([awayML]) > 130");

Upvotes: 2

Nikita K
Nikita K

Reputation: 406

Criteria operators have their own syntax to convert string literals to int values. You need to use them instead of system Convert.ToInt function:

Function Description Example
ToInt(Value) Converts Value to an equivalent 32-bit signed integer. ToInt([Value])
ToLong(Value) Converts Value to an equivalent 64-bit signed integer. ToLong([Value])

You can check the full reference of DevExpress criteria syntax here

Upvotes: 2

Related Questions