Kavya Durgam

Kavya Durgam

  • 2k
  • 26
  • 21.8k

Fetching the document from mongodb by passing the parameters

Dec 11 2017 2:51 AM
I need to check the document exixts in the mongodb based on  combination of 3 parameters.
this is the query worked on mongo db command prompt: 
I want to use this query in entity framework.
public object getFrequencyQuestionData()
var connectionString = "mongodb://localhost:27017";
MongoClient client = new MongoClient(connectionString);
MongoServer server = client.GetServer();
MongoDatabase db = server.GetDatabase("FormDataBase");
MongoCollection collection = db.GetCollection<Blog>("FrequencyQuestionForm");
// Here i want to call that query .. 
MongoCursor<Blog> cursor = collection.FindAllAs<Blog>();
var count = collection.Count();
string document = cursor.ToJson();
JToken token = JToken.Parse(document);
var jObject = JObject.FromObject(new { formdata = token, count });
return jObject;

Brought to you by:

Answers (1)