MongoDB Dictionary<string,decimal> store

Hi,

I’m using mongodb c# driver in my .net core application.
I’ve a dictionary data fields in table which is like
public IDictionary<string, decimal> monthlyBalance { get; set; }
but when storing dictionary in database the value takes in string not in decimal which is i declared in dictionary.

so please help me to solve this difficult problem.
Thank you !!

Hello,

I’m Using mongo c# driver v2.11.3. i just want insert dictionary in database.
and the dictionary is Dictionary<string,decimal>. i just simply insert string a key of dictionary and decimal a value of dictionary.but when i insert dictionary in database the value of dictionary takes as string.
it cannot store decimal value of dictionary.
here is the dictionary declared.

   [BsonId]
    [BsonRepresentation(BsonType.ObjectId)]
    public string _id { get; set; }
    public string ledgerTemplateId { get; set; }
    public string companyId { get; set; }

    [BsonRepresentation(BsonType.Int32)]
    public int periodId { get; set; }
    public List<CategoryItem> categories { get; set; }

    [BsonRepresentation(BsonType.Decimal128)]
    public decimal openingBalance { get; set; }

    [BsonRepresentation(BsonType.Decimal128)]
    public decimal currentBalance { get; set; }

    [BsonRepresentation(BsonType.Decimal128)]
    public decimal closingBalance { get; set; }
     
    public IDictionary<string, decimal> monthlyBalance { get; set; } = new Dictionary<string, decimal>();

    public IDictionary<string, decimal> dayBalance { get; set; } = new Dictionary<string, decimal>();

here is the sample database record .

in above image you can see the value of dictionary is taking as string.
is there anything which i do for store decimal value of dictionary.
How to do that? What should i do for?
I’'ll eagerly waiting for your response.
Thank you ?

Have you managed to solve it? I have the exact same issue.