Version 2.0 of the C# driver for MongoDB.
Questions tagged [mongodb-csharp-2.0]
187 questions
1
vote
1 answer
Using conditional clause in IFindFluent .SortBy block
I'm trying to apply a conditional SortBy to a find as follows:
var findFluent = Collection.Find (...)
.SortBy (record => record.IsActive)
.SortBy (record => record.Client != null
? record.Client.Profile.FirstName
:…

Graeme
- 773
- 1
- 8
- 18
1
vote
1 answer
Does MongoDB successful insert guarantee populated ID's?
We are using the MongoDB C# driver to insert a collection of records using InsertManyAsync.
We currently have code that iterates the entire collection after InsertManyAsync returns, confirming that the ID's are populated. I would expect that the…

GaTechThomas
- 5,421
- 5
- 43
- 69
1
vote
1 answer
How do I search nested criteria using MongoDB c# driver (version 2)?
I have a collection of documents that can contain criteria grouped into categories. The structure could look like this:
{
"Name": "MyDoc",
"Criteria" : [
{
"Category" : "Areas",
"Values" : ["Front",…

adam0101
- 29,096
- 21
- 96
- 174
1
vote
1 answer
MongoDB: How can I register conventions with Mongo 2.0
I am initializing the MongoClient in this way:
var client = new MongoClient(MongoConnectionString)
But how can I explain it that it should use the convention classes I've defined?
I've put them inside a class named BsonClassMap

Revious
- 7,816
- 31
- 98
- 147
1
vote
1 answer
Connection to MongoDB from MATLAB
I want to create a connection to my database in MongoDB from Matlab R2015a. I have tried with both the drivers for C# and Java but none of them seem to work and I don't know what the problem is.
For Java:
Code:…

IceWhisper
- 807
- 1
- 11
- 20
1
vote
1 answer
DistinctAsync against array sub documents with MongoDB C# 2.0 driver
In MongoDB 3.0 with the C# 2.0 driver, how do you get a distinct list of values using DistinctAsync from a document's array of sub documents?
I'm looking for the C# equivalent of this in the shell:
db.cars.distinct("parts.name",…

Dad of Many
- 21
- 5
0
votes
0 answers
How to understand mongoDB path with different commands?
I am going deeper in MongoDB with my project and facing complex mql queries where I have to update/remove sub-sub-..-sub document(s). I realized that I don't quite understand how the path selector works in MongoDB, because at every new query which…

Dmitry
- 661
- 5
- 21
0
votes
1 answer
How to fetch filtered document based on List of objetcs in Mongodb using C# mongodb driver
Consider this scenario: I wanted to fetch the filtered document from the documents collection of Student.
[
{
name:'arun',
gender:'Male',
physics:88,
maths:87,
english:78
},
{
name:'rajesh',
…

user1006544
- 1,514
- 2
- 16
- 26
0
votes
1 answer
How to partial update mongodb document in Web Api Patch request
I want to partial update fileds of my document that changed in the patch request and in every request the field probably changed for example one time Balance will be charged another time AccountHolder and others.
I want to update each specific…

Mohsen
- 21
- 5
0
votes
0 answers
Mongodb partial string matching with aggregation using C#
I am newbie in mongodb. I wanted to achieve something together. I was able do reach the goal separately.
bellow codeblock returns documents that has 'ke' in the field's text value-
var database = dbClient.GetDatabase("myDb");
var collection =…

Tohfatul Islam Milton
- 53
- 11
0
votes
0 answers
MongoDb C# client: use existing property value as id or generate new
I am migrating from RavenDB to MongoDB and therefore want to reuse existing classes deriving from
abstract class Entity
{
protected Entity()
{
}
protected Entity(string id)
{
this.Id = id;
…

yBother
- 648
- 6
- 25
0
votes
2 answers
Property with name "id" not deserialized in mongodb C#
I am trying to fetch a record from the mongo db in c#
Data in the mongodb collection:
{
id:0
parameter:"Unscheduled Demand"
remarks:"Formula Based"
value:89
}
Issue: id property is not getting deserialized from the data in C#.
C# class…

Kailash
- 1
- 1
0
votes
0 answers
C# console app net 2.0 How to get actual remaining time of another process running?
i have a c# console program .Im using .net 2.0 . Im launching an exe from my console program. That exe shows progress bar on taskbar.
Here i want to read progress percentage from that exe and want to display (1% 2% 3% etc) on my console app…

haseakash
- 31
- 1
- 6
0
votes
1 answer
Filter.Lte(x=>x.Price, "9") getting wrong results
I am applying the query to get records which are LessthanOREqual to 9, Price in MongoDB stored as string.
So whenever I appy filter like this:
filterDefinition&= Builders.Filter.Lte(x => x.Price, "9");
It will return records less than 9…

Tejas
- 296
- 3
- 12
0
votes
1 answer
Mongo DB c# query ALL element's property in nested array
I'm trying to get a filter with a certain condition to get documents that have an inner array of documents that have a property:
public class MyObject {
public List InnerObjects {get;set;}
}
public class InnerObject {
public…

Carlos Torrecillas
- 4,965
- 7
- 38
- 69