-1
When I query a Collection in mongodb, it returns a field of the string type.
[{"id":"1325","nome":produto1,"estoque":"10"}]
But I need to make this field a Json.
It is possible to do this in the query using Find()?
Collection.Find(_=>true).Sort(Builders<Model>.Sort.Descending("_Id")).FirstOrDefault();
class Model
{
[BsonId]
public ObjectId _Id { get; set; }
[JsonIgnore]
public string Mensagem { get; set; }
}
Looking at the code, it’s unclear what you’re trying to do, what the problem is and where you’re finding difficulty, present a [MCVE]
– Leandro Angelo
I just want to take a string and turn it into json. But I wanted to know if it is possible to do this conversion directly in the query of Mongo.
– Carlos
If the object is compatible yes, it would be better for you to post the json string you are receiving and the object structure for de-ralization, this has nothing to do with Mongo. Note that your string has different attributes from the model
– Leandro Angelo
[{"id":"1325","name":product1,"stock":"10"}] The string is saved like this. It is mounted in the code and saved as a string in the bank.
– Carlos
Where? in the message field? Wouldn’t it be better for Block to have the same properties?
– Leandro Angelo