Questions tagged [bsondocument]

25 questions
3
votes
0 answers

Litedb : Convert string to BsonDocument and vice-versa

When i convert bson to string using the following : var stringDoc = LiteDB.JsonSerializer.Serialize(bsonDocument); i'm getting the following : {"_id":{"$oid":"62f3c9299c37811224131269"},"Name":"John Doe","Phone":"0778636316"} When i try to convert…
Ahmed HM
  • 110
  • 1
  • 9
2
votes
1 answer

Cannot deserialize the JSON object into 'MongoDB.Bson.BsonDocument' type

So I have a JSON file that I want to convert to an object that contains a BsonDocument but I get an error. My JSON file is: { "words": { "wordList": { "d": "duck", "t": "truck", "l": "luck", "s": "suck" } } } And…
Rafa
  • 25
  • 5
2
votes
2 answers

How to deserialize query with LUUID value to BsonDocument

I'm trying to deserialize filter with LUUID (or NUUID in this example) to BsonDocument: var tmpQry = "{'ValueId': NUUID('ca7ac84f-18bf-42f0-b028-333ed144c549')"; var tmpBson =…
2
votes
1 answer

xml parsing using c# (BsonDocument)

Below is my xml file and I want to parse the AttributeSets element. want to store all the data to mongoDB database using C#
user11617010
1
vote
1 answer

MongoDB - Filter data matching one of the options

I'm trying to filter MongoDB data using a query written using a BsonDocument where a parameter - eg "name" - equals one of an array of possible values, but can't get the correct syntax for this: Eg "name" equals "bill" or "name" equals "fred" I've…
1
vote
1 answer

How to check for nested property in BsonDocument - Contains doesn't work

When I wrote code to grab a nested property, it fails when the entire path doesn't exist - which is fair enough bsonDoc["Meeting"]["Session"]["Time"] I can't see any way to protect against this, writing bsonDoc.Contains("Meeting.Session.Time")…
PandaWood
  • 8,086
  • 9
  • 49
  • 54
1
vote
0 answers

How to search for a field with a value deep in BSON Document in Java

Given I have this sample BSON Document which I retrieved from Mongo DB. { "field1": "text1", "field2": { "field2Sub1": "text2" }, "field3" : [ { "field3Sub1": "text3", "field3Sub2": "text4" …
Artanis Zeratul
  • 963
  • 2
  • 14
  • 40
1
vote
1 answer

C# MongoDB BsonDocument not getting serialized to custom class using BsonSerializer

I am having an issue with serializing BsonDocuments using BsonSerializer. I am using var bsonDoc = collection.Find(...) to pull a single document from a MongoDB database. I then try to serialize it using var strongTypedDocument =…
user20358
  • 14,182
  • 36
  • 114
  • 186
1
vote
1 answer

Command aggregate failed: Remote error from mongot :: caused by :: \"origin\" must be a date, number, or geoPoint (from \"compound.should[1].near\")

I'm using MongoDB Atlas and creating search pipeline using C# dictionary object then serializing it to json and then parsing the json string to BsonDocument. In $search stage I'm using near object in compound should with origin date for sorting. As…
1
vote
0 answers

Converting between MongoDB.Bson versions

I have an application writing BsonDocuments created by MongoDB C# driver (v1.10.xxx) as byte array to RabbitMQ. Then I have another application which was using the same driver to read and convert the byte representation of the BsonDocument back to…
Taha Paksu
  • 15,371
  • 2
  • 44
  • 78
1
vote
1 answer

How to check if key exists in BsonDocument or not using Mongodb C# driver?

I am receiving data (BsonDocument) from mongodb using a C# driver like this: { "_id":ObjectId("5c8730688a247070ca5e4a15"), "visitorEmail":"UnRegistered", "visitorName":"Guest040704", "agentEmail":"salman@blauda.com", …
Fahad Hassan
  • 781
  • 10
  • 20
1
vote
1 answer

Insert json file containing an array of json documents into ammongodb collection using BsonDocument BsonArray

I am working on a method to asynchronously read the contents of a json file ( containing an array of json objects) and insert it into a mongodb collection but I cannot figure out what the issue is. There is no error when debugging, but my collection…
TropicalViking
  • 407
  • 2
  • 9
  • 25
1
vote
1 answer

Howto set id of bsonDocument?

I got a complex class (named ArticleData). Now, when i create a bsonDocument using the following code, the resulting bsonDocument automatically gets a document id (even though i try to set "_id" myself): // bson document created from ArticleData…
Thariama
  • 50,002
  • 13
  • 138
  • 166
0
votes
0 answers

error when serializing a BsonDocument using System.Text.Json in .net 6.0

I have a c# class as following: public class Product { public string ProductName { get; set; } public int ProductCount { get; set; } public BsonDocument ProductMetadata { get; set; } } The BsonDocument is coming from the…
0
votes
0 answers

Accepting any object structure of data in web api method c# dotnet core

Required to write an API which should accept a request body with any structure to convert to BsonDocument and save it. Something similar as below but not seems working with Object type. [HttpPost("InsertBsonUserWithInput")] public async…
1
2