-
Type: Bug
-
Resolution: Fixed
-
Priority: Blocker - P1
-
Affects Version/s: 2.22.0
-
Component/s: None
-
None
-
Fully Compatible
-
Not Needed
-
Summary
When having a property of type long named Count, the translation of a Linq-query with greater than fails.
Please provide the version of the driver. If applicable, please provide the MongoDB server version and topology (standalone, replica set, or sharded cluster).
How to Reproduce
Test document:
[BsonIgnoreExtraElements]
public class TestDoc
{
public long Count { get; set; }
}
Code:
var settings = MongoClientSettings.FromConnectionString("mongodb://localhost");
settings.LinqProvider = MongoDB.Driver.Linq.LinqProvider.V3;
var client = new MongoClient(settings);
var db = client.GetDatabase("test");
var coll = db.GetCollection<TestDoc>("long_count_fail");
var doc = new TestDoc() { Count = 123 };
await coll.InsertOneAsync(doc);
var countGreaterThanZero = coll.AsQueryable().Where(x => x.Count > 0).ToList();
Console.WriteLine(countGreaterThanZero.Count); // 0 – failure
var countEquals123 = coll.AsQueryable().Where(x => x.Count == 123).ToList();
Console.WriteLine(countEquals123.Count); // >= 1 – works
Additional Background
In Version 2,20.0 of the driver, the failure could not be observed, a change in v2.22.0 is suspected to cause the error.