1

I am using mongodb driver in c#. I can create query for CRUD operations sqlserver in c# . But i need to Create query for mongodb and execute it . For an sample i attached Delete Delete Query

string query = string.Format("DELETE FROM {0} WHERE {1}"

ExecuteNonquery method i can execute it in sqlConnection

How i do this in mongodb?

1
  • MongoDB CRUD Operations. Read it. Also don't spam tags just to get attention. Commented Nov 7, 2017 at 5:58

1 Answer 1

1

You should see FilterDefinitionBuilder TDocument which provides a type-safe API for building up both simple and complex MongoDB queries.

For example to build up the filter { x: 10, y: { $lt: 20 } }, you can use below:

var builder = Builders<BsonDocument>.Filter;
var filter = builder.Eq("x", 10) & builder.Lt("y", 20);

You can see more examples on mongo-csharp-driver tests for FilterDefinitionBuilder class.

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

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.