1

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.

2 Answers 2

1

I found the answer and it sucks: it can't be done at this time.

See: https://jira.mongodb.org/browse/CSHARP-1445

Sign up to request clarification or add additional context in comments.

Comments

0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.