Questions tagged [mongodb-csharp-2.0]

Version 2.0 of the C# driver for MongoDB.

187 questions
0
votes
1 answer

C# MongoDbDriver migrating obsolete Count to replacement methods

For some time we've been getting warnings in our code: Warning CS0618 'IMongoCollection.Count(FilterDefinition, CountOptions, CancellationToken)' is obsolete: 'Use CountDocuments or EstimatedDocumentCount instead.' So we want to "update".…
JHBonarius
  • 10,824
  • 3
  • 22
  • 41
0
votes
1 answer

Mongodb c sharp driver document update error

I am using c# mongo db driver to insert and update a document. First i insert a record and then I try to update a specific field of record using FindOneAndUpdateAsync method. I am able to update it properly but after update I am getting a error…
0
votes
1 answer

How can I use latest MongoDB C# Driver to delete an element within a nested array of complex array objects based on multiple conditions?

The overall goal is to be able to perform a lookup of a meal based on the userid, and mealid. If that item is found, I want to be able to delete only the entire element that matches both the userid and mealid. Currently, After sending the request…
0
votes
0 answers

MongoDb Indexing with deference of 2 dates

In my Mongo db collection have 2 date fields TimeStamp, OpEndTime, I need to take order by OpEndTime-TimeStamp. It is working with a small amount of data. For huge data throw exception out of ram space. So need to create the index with difference…
0
votes
0 answers

POCO object cannot be serialized

I ma trying to use POCO objects derived from an existing Mongo DB and collection. I am just starting and I decided to use the 'sample_mflix' database that is given as an example database. I am currently using the 'movies' collection. When I try to…
Kevin Burton
  • 2,032
  • 4
  • 26
  • 43
0
votes
1 answer

Exception when querying with an explicit Interface using MongoDB C# driver

I need to construct a query using as a FilterDefinition an explicit Interface but it throws an exception saying : System.InvalidOperationException Message={document}.Pointer is not supported. Source=MongoDB.Driver I have tried this with normal…
Sebastian Inones
  • 1,561
  • 1
  • 19
  • 32
0
votes
0 answers

MongoDB c# Driver, Update an entity field with data from another entity field

I'm using the following packages: MongoDB.Driver - Version="2.7.2" MongoDB.Driver.Core - Version="2.7.2" My model looks something like this: data: { field1 :"1" }, history: [{ field1 :"0" }] Now I want to create an update definition which…
Rick van Lieshout
  • 2,276
  • 2
  • 22
  • 39
0
votes
1 answer

MongoDB CSharp In Filter Is Not Correct

I have a collection of Communication documents with an Int field called CommId and I am trying to find all matching documents that are contained in an array of ints using the code below. If this query worked, it should return 5 documents. var…
Ken Tola
  • 671
  • 1
  • 8
  • 18
0
votes
1 answer

How to connect mongodb from another windows server

How to connect mongodb from another windows server. I have a windows server with public IP. I have installed monngoDB on that server. I have created database and as well as user on mongodb. Now I am trying to connect mongodb using compass from my…
0
votes
1 answer

Store Json string as MongoDB array in C#

I want to store a JSON string in an array format in MongoDB.This is my C# code for storing notification into MongoDB, here the field "Event_meta" field sending as a JSON string format to MongoDB. public async Task Handle(TaskPropertyUpdatedEvent…
0
votes
1 answer

Timeout exception trying to connect to mongodb single-node replica set

Any thoughts as to what is wrong would be greatly appreciated. Thank you! Server started with the following flags mongodb-win32-x86_64-2008plus-ssl-4.0.2\bin\mongod --sslMode disabled --dbpath "C:\Users\foobar\AppData\Local\Temp\sj5ufivo.hgy" --port…
0
votes
0 answers

How to intercept AsQueryable() of mongodb c# driver 2.x?

I have a wrapper class for IMongoCollection Collection. I expose a function for AsQueryable(): public virtual IQueryable AsQueryable() { return Collection.AsQueryable(); } I need to intercept the execution of queries (start and end of the…
Aviko
  • 1,139
  • 12
  • 21
0
votes
1 answer

Filter Query in Mongodb using multiple Id's(Inner array)

CommentCollection { "_id":"5b63f0f23846b70011330889", "CommentType":"task", "EntityReferenceId":"6082ef25-6f9a-4874-a832-f72e0f693409", "Threads":[ { "_id":"69bcef71-3695-4340-bdec-4a6e4c58c490", "CommentType":"task", …
0
votes
1 answer

Fetch untyped data from MongoDB gives "Unknown discriminator value"

We're using log4mongo-net to save log4net issues in mongo db. Now we've made a simple page where we can browse the logs directly from the browser by reading it untyped from mongo db. But, when there is a log with for example a POST containing an…
erik_nw
  • 837
  • 5
  • 11
0
votes
1 answer

Possible ways to run direct Mongo queries in C# like SQL queries

I am unsing Mongo DB and C# (.Net) to build my web application. I want to run Mongo queries in my .Net application like SQL queries using ADO.net. What are the possible ways to run direct Mongo queries in C# ?