Questions tagged [mongodb-.net-driver]

The official MongoDB .NET Driver provides asynchronous interaction with MongoDB.

MongoDB .NET Driver

The next generation .NET driver for MongoDB

Introduction

The official MongoDB .NET Driver provides asynchronous interaction with MongoDB. Powering the drivers is a Core library and a BSON library.

Features

  • Driver - A completely async driver to talk with MongoDB.
  • GridFS - A distributed file system built on MongoDB.
  • Core Driver - The MongoDB Driver is built on top of a new Core library which anyone can use to build alternative or experimental high-level APIs.
  • BSON Library - A standalone BSON library, with a serialization infrastructure that you can use to build high-performance serializers.

MongoDB .NET Driver Documentation

2641 questions
1
vote
1 answer

C# MongoDB Driver OutOfMemoryException

I am trying to read data from a remote MongoDB instance from a c# console application but keep getting an OutOfMemoryException. The collection that I am trying to read data from has about 500,000 records. Does anyone see any issue with the code…
degmo
  • 177
  • 1
  • 18
1
vote
1 answer

mongodb c# push or insert if field is null

I am using the mongodb c# driver and attempting to insert an initialized array when the field is null, and push when an array already exists at the address ( at this stage I am just assuming an array exists at the address field if it is not null ).…
xxdefaultxx
  • 175
  • 1
  • 12
1
vote
0 answers

How to aggregate time slices and compute total elapsed in MongoDB with C# driver

I have a MongoDB collection of objects like this. { "_id" : "56fd034268f44e1eccb8a775", "Period" : { "StartDateTime" : ISODate("2016-04-02T06:00:00Z"), "EndDateTime" : ISODate("2016-04-02T08:00:00Z") }, ...…
Marcello
  • 879
  • 6
  • 20
1
vote
1 answer

querying a collection against a byte property in mongodb with c# driver

I am fairly new to mongodb and I am trying to query a collection with byte property but I am getting an invalid cast exception. To summarize, public class MongoDbAddressCollection { private IMongoCollection collection =…
Ahmet Keskin
  • 1,025
  • 1
  • 15
  • 25
1
vote
1 answer

Group by day using $dateToString in C# MondoDB Driver 2

I want to group an aggregate by day (not dayOfMonth or Year, just absolute day). Therefore I want to use the $dateToString operator as shown here: $dateToString: { format: "%Y-%m-%d", date: "$date" }. Is there a way to use an expression for this…
hansmaad
  • 18,417
  • 9
  • 53
  • 94
1
vote
1 answer

How can I find by ID in Mongo C# Driver 2.2.3

My source code is not working public async Task AdjustPrice(string id) { var filter = new BsonDocument("_id",id); return View(await Context.Rentals().Find(filter).FirstOrDefaultAsync()); }
1
vote
2 answers

Cant Mock my Get() function from my repository - MongoDB.Driver 2.2.3

In my unit test I want to test my method that I created for filtering data from MongoDB. When I try to mock my function like this: _repo.GetFluent((Arg.Any>>())) .Returns(x =>…
1
vote
1 answer

How to pass json from c# to mongodb stored js

We are trying to post json string from c# to mongodb stored javascript using driver ver 1.8 Here is my js function : function addCorporate (json) { db.Corporate.save(json); /* obj = JSON.parse(json); if(obj.corporateName) { …
Jatin
  • 11
  • 4
1
vote
1 answer

Where must be WriteConcern implemented?

This is a code segment where I will insert PLC data into MongoDB but I am not sure as to where must WriteConcern be implemented? var connectionString = "mongodb://10.52.124.186:27017/"; // Establish connection from the client to the server…
Arjun
  • 9
  • 1
  • 7
1
vote
2 answers

Deserializing a C# Dictionary in MongoDB Returns Null

I have a simple class: public class Foo { public ObjectId Id { get; set; } public Dictionary Bar { get; set; } } Nothing else, no custom mappings, etc. When I insert it into MongoDB, it works perfectly, but the Bar property…
Ricardo Peres
  • 13,724
  • 5
  • 57
  • 74
1
vote
1 answer

How do I implement TryGetItemSerializationInfo on a Bson Array Serializer?

We are using MongoDb to store product attributes and have created a custom array serializer to take a dictionary and serialize it in a custom format. The format takes the key and value of each dictionary item and stores it as a single array item…
rrrr-o
  • 2,447
  • 2
  • 24
  • 52
1
vote
1 answer

Using c# Mongodb driver 2.2, how to find max record when grouped by on a particular field

I have a collection as "UserRecords". structure for this is as follows { "_id" : "ee654ce6-e50d-4243-8738-35c087a85e67", "_t" : "Animals", "ClickedOn" : NumberLong(1452600122), "Category" : "Nature", "UserId" : "a1", …
Learner
  • 1,277
  • 3
  • 15
  • 34
1
vote
1 answer

MongoDB C# List the latest of all entries on a sub document

Is it possible to list all the restaurants and their latest grade, if grades is a an array within a restaurant? { "_id" : ObjectId("56bf7957b5e096fd06b755b2"), "grades" : [ { "date" :…
BanksySan
  • 27,362
  • 33
  • 117
  • 216
1
vote
2 answers

MongoDB 3.2 C# driver version 2.2.3.3 Gridfs Download large files more than 2gb

I am uploading files using the following code: using (var s = File.OpenRead(@"C:\2gbDataTest.zip")) { var t = Task.Run(() => { return fs.UploadFromStreamAsync("2gbDataTest.zip", s); }); return t.Result; } //works for…
Raj
  • 173
  • 1
  • 7
1
vote
0 answers

MongoDB Projection on nested collection with csharp driver in .NET

In the near future I want to migrate from SQL Server to MongoDB. For now I'm just playing around with all the possibilities and testing out the best schema design. I stumbled on a question. Let me summarize the issue. I have 30 manufacturers that…
Nesse
  • 373
  • 4
  • 14
1 2 3
99
100