I am using .Net MVC with Entity Framework. In my Model Class I have these 2 properties:
public string Content { get; set; }
[NotMapped]
public dynamic DynamicContent { get { return Newtonsoft.Json.JsonConvert.DeserializeObject<dynamic>(this.Content); } }
the "Content" contains a JSON string and the DynamicContent is a dynamic property based on the JSON string.
Can I modify the contents of the dynamic property? For example: I can read a value like this
DynamicContent.title
but how can I set its value from the controller?
DynamicContent.title = "myvalue" does not work.
dynamic. Create a model object from the entity object and extend it with a title property. During the conversion to a model object you can handle the specifics of the dynamic object creation. I'm sure your domain problem doesn't necessary call for a solution that involvesdynamic.