I am using MongoDB and I am trying to make a query from C#.
I have a problem: I am using “gt” with a Long and for some reasons MongoDB returns me, as first value, the same value I use in the query, as you can see from the following image.
Query result
This is a strange behavior for me, but I found out that if I use “Long(my_number)” instead of “my_number” the query works as expected.
To recap the situation:
Strange behavior:
{ "$and": [{"myDataStruct.nid": {"$gt":1717520199654397472}},
{"myDataStruct.res":"0"}]}
Sort {"myDataStruct.nid":1}
This works:
{ "$and": [{"myDataStruct.nid": {"$gt":Long(1717520199654397472)}},
{"myDataStruct.res":"0"}]}
Sort {"myDataStruct.nid":1}
My problem is that i don’t know how to specify the query with “Long” from C#.
The current filter I am building with C# behaves as the strange behavior query:
var filter = Builders<myDataStruct>.Filter.And(
Builders<myDataStruct>.Filter.Gt(x => x.nid, (long)from),
Builders<myDataStruct>.Filter.Eq(x => x.Res, "0"));
Anybody has a suggestion?
Thanks