Version 2.0 of the C# driver for MongoDB.
Questions tagged [mongodb-csharp-2.0]
187 questions
0
votes
1 answer
Send mongodb filter string threw http to the web api
I am looking a way to send a mongodb filter from the webapp threw http to the web api.
In the webapp controller: serialize or deserialize then Encrypt
var filter = Builder.filter.Eq("firstName", "Foo");
In the web…

Sinan
- 898
- 1
- 9
- 23
0
votes
0 answers
How to use manual references when inserting and retrieving relational data using MongoDb and its C# driver
As it may be obvious of my question, I am coming from a relational database way of thinking (SQL server) and using ORMs (Entity Framework). I want to do the same things now in MongoDB and I am having some troubles with it.
Let me explain a simple…

roostaamir
- 1,928
- 5
- 24
- 51
0
votes
0 answers
how can search data on multiple field on mongoDB with C#?
I am using MongoDB with C# Driver
I try to fetch data based on search as an like from collection using following code:
col.Find(new BsonDocument(new BsonElement("Name", new BsonRegularExpression(search)))).ToList();
it's work for single field…

Pradip Talaviya
- 399
- 2
- 8
- 22
0
votes
1 answer
Aggregation with Mongodb c# Driver 2.4 not working
When using the commands as below, it returning null.
var pipeline = new BsonDocument[] {
new BsonDocument{{"$group", new BsonDocument{{"_id", "$BrandId"}}}}
};
var brands = context
…

GSH
- 239
- 1
- 5
- 16
0
votes
1 answer
Unable to determine the serialization information IIF
I have a price range query I'm trying to write for my C# code and depending on the currency type of the product I need to query the correct field
var minPrice = builder.Gte(s => s.Price.CurrencyCode == "USD" ? s.Price.Usd : s.Price.Foreign,…

Eman
- 1,093
- 2
- 26
- 49
0
votes
1 answer
Why should I define mongoDB collection at global level - It's thread safe
I am using C++/Cli to work with mongoDB latest C# driver compiled as a dll. I use an instance of the driver in the C++ code.
I have tried many times. If I build more than one threads, each trying to update a document in the same collection, it…

Harold
- 33
- 5
0
votes
1 answer
Different behavior in mongodb query projection using async
I am implementing a search method in c#. The issue is that the score metadata is not included in the result, causing it to exception on the last line. It's like the find is being done without the project clause. I am using version 2.2.4.26 of the…

Aaron Newman
- 549
- 1
- 5
- 27
0
votes
1 answer
MongoDB strongly typed filter and Find()
I'm pretty new to MongoDB and the MongoDB C# driver.
To make the code more readable (and reliable) I decided to give strongly typed objects a try. Therefore I created a POCO...
Only Id and Payload are initially present in the database.
internal…

lapsus
- 2,915
- 2
- 32
- 61
0
votes
1 answer
C# mongodb driver - update in sub array not working
I have the following model (only the improtant type):
public class Model
{
[BsonId]
public ObjectId ModelId;
public List Games;
}
public class Game
{
[BsonId]
public ObjectId GameId;
public List Matches;
}
public…

Ori Refael
- 2,888
- 3
- 37
- 68
0
votes
2 answers
How to force serialization of decimal values inside dictionaries as doubles in mongodb csharp driver?
I have the following dictionary:
var dict = new Dictionary {
{ "decimal", 3.503m },
{ "int", 45 }
};
var serializedString = dict.ToJson();
By default that is serialized as:
{ "decimal" : { "_t" : "System.Decimal", "_v" : "3.503"…

lekrus
- 41
- 3
0
votes
1 answer
c# mongodb upsert with positional operator issues
Lets say I have an object which only contains an array
public class A
{
[BsonId]
public ObjectId Id;
public int[] arr;
public A()
{
arr = new [5];
}
}
when I want to update a certain index in…

Ori Refael
- 2,888
- 3
- 37
- 68
0
votes
1 answer
C# mongodb ObjectId useage risks
I was watching on Mongodb ObjectId object.
It seems to be non-safe object to expose to my client (even its his own SessionId).
Though im using the following code to generate random ObjectIds:
var timestamp = DateTime.UtcNow;
var machine =…

Ori Refael
- 2,888
- 3
- 37
- 68
0
votes
1 answer
C# mongodb 2.0 Find and project ordered part of an array
I have the following codeblock:
var r = this.collections.competitions.Find(filter)
.Project(x => x.TeamRanks)
.Project(t => t.Logo)
…

Ori Refael
- 2,888
- 3
- 37
- 68
0
votes
1 answer
oData filter not working on navigation property with MongoDB and Web API
Controller looks like
public class NodesRestController : ODataController
{
private INodeService _nodeService;
public NodesRestController(INodeService nodeService)
{
_nodeService = nodeService;
}
[EnableQuery()]
…

Raas Masood
- 1,475
- 3
- 23
- 61
0
votes
1 answer
MongoDb 3.0 C# updating subdocument of subdocument
Below is an example of my document. I am trying to update the CostReports part based on the id of the CostReportingPeriods element.
{
"_id" : "240106",
"CostReportingPeriods" : [
{
"FyBgnDt" : ISODate("2000-01-01T05:00:00.000Z"),
…

collinszac10
- 198
- 1
- 1
- 12