Hesam Asnaashari
Hesam Asnaashari

Reputation: 29

Store object in document ( MongoDB & ASP.NET Core 6 )

I'm trying to store an object in the document. This is my entity:

public Guid Id { get; set; } 
public string CreatedBy { get; set; } 
public string CreatedByIp { get; set; } 
public DateTime CreatedAt { get; set; }  
public string LastUpdatedBy { get; set; } 
public string LastUpdatedByIp { get; set; } 
public DateTime? LastUpdatedAt { get; set; }
public object LastContext { get; set; } 

LastContext object that contains multiple properties must be stored in the document, but this is what is stored in the document:

enter image description here

Also, because of the architecture, I should not use MongoDB attributes for entity properties.

Upvotes: 2

Views: 616

Answers (1)

1SaeedSalehi
1SaeedSalehi

Reputation: 373

You can map your class to another class with same properties with JObject or JToken type , which can be stored in Mongo

Upvotes: 2

Related Questions