We query a schools collection by two fields using the mongocsharpdriver (v2.0.0) API like:
db.GetCollection<School>("schools").Find(x => x.City == myCity && x.State == myState);
Will the order of the fields listed in the lambda expression generate a query to leverage a compound index with the same order: { "city": 1, "state": 1 }
?
I'm fairly new to mongodb, but if I understand correctly, we could create a second (reversed) compound index: { "state": 1, "city": 1 }
to ensure one of them is used. I'm just more interested how the lambda is translated and couldn't find what I was looking for in mongodb's documentation.