Reputation: 123
Is there a way to write a query with FilterDefinitionBuilder and Linq? The reason I'm asking is because I need to use the $withinSphere operator which is not supported by Linq directly. However, I can create a filter using FilterDefinitionBuilder. Combining both seems anything but obvious.
I know that the old legacy driver had a class called Query which allowed one to do something similar. However, that class no longer exists.
Upvotes: 1
Views: 1293
Reputation: 12138
This is implemented as of 2.3 (see link from Hector). Usage as taken from the corresponding unit test is:
var filter = Builders<Root>.Filter.Eq(x => x.B, "Balloon");
var root = __collection.FindSync(x => x.A == "Awesome" && filter.Inject()).Single();
Upvotes: 0
Reputation: 123
I found the answer and it sucks: it can't be done at this time.
See: https://jira.mongodb.org/browse/CSHARP-1445
Upvotes: 1