I have a model which contains a JSON string, and would like to keep the parsed JSON.NET object along for the ride to prevent unnecessary re-parsings.
For example
public class JsonData {
public Guid Id { get; set; }
public string Json { get; set; }
}
I’d like to keep a JObject in there, and if possible on Json string’s set re-parse it. I wouldn’t want to store it in the database. As I write this, though, it just feels wrong…
What’s a good way to carry an object which is the same ‘data’ (view?), just serialized on top of a model?
I’m not sure this is what you mean, but you can add the
[NotMapped]annotation to properties on your POCO that you want to use only in code and not store in the database;A more complete example for your Json cache needs, deviating from POCO land though;
You should be able to create a base class with the getter and just call a method there to set _jsonCache to null. That’ll keep your classes a bit cleaner.