Simple Query with PredExp for AND (C#)


#1

Hi,

I want to execute a Query like this SQL:

WHERE FieldA > 123456 AND FieldB == "Open"

Filter plus a PredExp:

statement.SetFilters(Filter.Range("FieldA", 123456, long.MaxValue));
statement.SetPredExp(PredExp.And(2), PredExp.StringValue("Open"), PredExp.StringEqual(), PredExp.StringBin("FieldB"));

client.Query() returns the error {“Error Code -1: Query Failed: Error Code 4: Parameter error”} I tried to change the order of the PredExp items but I have always the same error.

C# driver v3.6.3

HOW I can obtain my query?

As someone else pointed out in StackOverflow .SetFilters() suggests that I can use MORE filters, not just one. I found this syntax for PredExp ridiculous. I’ll’ complete this query today but … next month I’ll not remember what is that magic And(2) and what logic I have to follow to set the PredExp properly.

It is a little bit frustrating that I have to search how to use it (and I haven’t found the solution in 1 hour).

I expect to use the PredExp in this way:

statement.SetFilter(Filter.GreaterThan("FieldA", 123456))
    .And(PredExp.AreEqual(PredExp.StringBin("FieldB"), PredExp.StringValue("Open")));

Thanks.


#2

Find out the right sintax. I had problems also because the Set name was not specified (and that is a valid condition!) returning the error for mssing index.

This is the syntax:

statement.SetFilters(Filter.Range("FieldA", 123456, long.MaxValue));
statement.SetPredExp(
    PredExp.StringValue("Open"), 
    PredExp.StringBin("FieldB"), 
    PredExp.StringEqual()
);