Questions tagged [mongodb-csharp-2.0]

Version 2.0 of the C# driver for MongoDB.

187 questions
1
vote
1 answer

Repository pattern and aggregate root pattern. How to make SaveChanges in repository?

We recently started using repository pattern and aggregate root pattern. This is all working super well when I am tracking the changes using EntityFramework, and I am able to call SaveChanges, when I am done with the work on my aggregate. Now my…
Kristian Barrett
  • 3,574
  • 2
  • 26
  • 40
1
vote
1 answer

Selecting from a IMongoQueryable collection with a Linq Expression throws an error [c# driver 2.2.4]

Using the mongoDb c# driver 2.2.4, selecting from a IMongoQueryable collection with a Linq Expression throws an error because of my Id field. Here is the code: MongoDB.Driver.MongoClient myClient = new…
1
vote
0 answers

mongodb c# driver How to insert nested entity with generated id

I'm trying to insert nested entity, it's create the nested entity but its id remains null. i cant find an answer or example anywhere else. please help me. what i did? i have 2 objects menu { Id items[] } Item { Id } i mapped the two…
1
vote
0 answers

In MongoDB for C# is there a way to exclude members implicitly but still be able to get them explicitly?

Is there a way to implicitly exclude certain fields/types in some DB model in C#'s MongoDB, while still allowing to get them explicitly? for instance, I have a Model with two big lists: public class Model { public string SomeName; public…
Tar
  • 8,529
  • 9
  • 56
  • 127
1
vote
1 answer

JSON reader was expecting a value but found 'function'

I have a collection that contains BsonJavascript object. { "Name" : "HourlyMP", "MapFunction" : function(){ var _id = this.srcip + " - " + this.hour var valueData = { ip: this.srcip, session: 1 …
Alisettar Huseynli
  • 944
  • 1
  • 11
  • 24
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
vote
1 answer

c# Mongodb 2.0 driver get UpdateManyAsync result

Is there any way to get the updated collections after/before the update? What I can think of is pretty heavy. get what i want to update using filter. update everything i got in the previous state get all by ids again and check what has been…
Ori Refael
  • 2,888
  • 3
  • 37
  • 68
1
vote
1 answer

Is there a way to check for insert errors on the mongodb database when using writeconcern 0 unacknowledged?

My system requires heavy database writes from thousands of requests per second. In order to minimize response times, I've started to learn about write concerns, and using the unacknowledged / writeconcern 0 will help, however as expected in its…
Nick
  • 2,735
  • 1
  • 29
  • 36
1
vote
1 answer

Getting started with MongoDB on C# - query does not work

I am starting with MongoDb on c#. At the end, I need function which simply checks if the user exists in DB -thats it. I am a complete beginner so naturally example right from MongoDb tutorial does not work here are examples: public static async…
Anna F
  • 41
  • 6
1
vote
1 answer

MongoDb find documents by regex using indexes alternative c#

I have the following query query = query & Builders.Filter.And(query, Builders.Filter.Regex(p => p.email, '^' + search)); But i know that MongoDb can't use indexes with regex queries. Is it possible to implement an alternative…
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46
1
vote
1 answer

MongoDb indexes with $exists filter

I have an array in documents, but different queries use it in different way. It could be an $exists query or search by nested array's item fields. Which indexes should i make in these cases? Also, i use MongoDb v. 3.0.2 & Official c# driver v. 2.0
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46
1
vote
1 answer

MongoDB add query at runtime with c# driver > 2.0

I would like to have the possibilitie to add queries at runtime. My Solution with the "old" driver was like this. // A List does hold the queries List QueryConditionList = new List(); void…
U.Ho
  • 11
  • 3
1
vote
1 answer

MongoDb c# driver 2.0 bulk update error

I try to perform bulk update operation using Official Mongo c# 2.0 driver via the following code : var query = Builders.Filter.In(p => p.userId, listBounce.Values.ToList()) & Builders.Filter.In(p => p.ID, …
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46
1
vote
0 answers

MongoDb count of elements with grouping by timespan

I don't understand how to implement the following query via MongoDb : I need to take a count of documents but with condition that only one document will be taken for each time span which equals 30 minutes. I.e. if in 60 minutes time span i have two…
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46
1
vote
1 answer

MongoDb c# 2.0 driver - how can i calculate count of aggregations on server?

When i ran dbCollection.Aggregate().Group(groupby).Match(query) I haven't any extention method to get a count of records what was aggregated. But i can run ToListAsync and then get Count(). How can i receive a count of records ? I have MongoDb v…
Vladyslav Furdak
  • 1,765
  • 2
  • 22
  • 46