Search Results

Search found 1 results on 1 pages for 'user3684208'.

Page 1/1 | 1 

  • MongoDB search in C#

    - by user3684208
    I have a problem with querying MongoDB. In my code I have a method Get which has as a parametar a Dictionary. It should go through the database and query it, comparing string and then object. So, i always get a problem with this object part, QueryDocument won't take in an object type because it isn't an BsonValue. I have tried to cast it but it won't work. Do you have any suggestions ? Thanks Code part : public List<ExceptionViewModel> Get(Dictionary<string, object> FilteredExceptions) { MongoClient mongo = new MongoClient(); MongoServer mongoServer = mongo.GetServer(); MongoDatabase db = mongoServer.GetDatabase("Aplikacija"); MongoCollection collection = db.GetCollection("Exceptions"); List<ExceptionViewModel> Get = new List<ExceptionViewModel>(); foreach (KeyValuePair<string,object> item in FilteredExceptions) { var query = new QueryDocument(item.Key.ToString(),item.Value); foreach (ExceptionViewModel exception in collection.FindAs<ExceptionViewModel>(query)) { Console.WriteLine("{0}", exception.BrowserName); } } return Get; }

    Read the article

1