Hi
I get inconstant results from MyCollection.AsQueryable().FirstOrDefaultAsync(...)
while MyCollection.Find(...).FirstOrDefaultAsync() works fine.
For example:
Given the following test
public class TestObject
{
[BsonId]
public string DeviceID { get; set; }
public List<string> Sessions = new List<string>();
}
async private void demo(theTestModel model)
{
var id = "heavy";
var test = model.Database.GetCollection<TestObject>("test");
model.Database.DropCollection(test.CollectionNamespace.CollectionName);
var heavy = new TestObject() { DeviceID = "heavy" };
var lite = new TestObject() { DeviceID = "light" };
for (int i = 0; i < 260000; i++) heavy.Sessions.Add(Guid.NewGuid().ToString());
for (int i = 0; i < 1000; i++) lite.Sessions.Add(Guid.NewGuid().ToString());
test.InsertOne(heavy);
test.InsertOne(lite);
var test1heavy = await test.Find(x => x.DeviceID == id).FirstOrDefaultAsync();
// test1heavy contains the expected results
var test2heavy = await test.AsQueryable().FirstOrDefaultAsync(x => x.DeviceID == id);
// test2heavy is null
id = "light";
// test1light contains the expected results
var test1light = await test.Find(x => x.DeviceID == id).FirstOrDefaultAsync();
// test2light contains the expected results
var test2light = await test.AsQueryable().FirstOrDefaultAsync(x => x.DeviceID == id);
}