I have a document model to store in RavenDB but I don't want to store a calculated property. How do I tell RavenDB to ignore this property?
In the below example I don't want to store Duration
.
public class Build
{
public string Id { get; set; }
public string Name { get; set; }
public DateTime StartedAt { get; set; }
public DateTime FinishedAt { get; set; }
public TimeSpan Duration { get { return StartedAt.Subtract(FinishedAt); }}
}
Just decorate the Duration
property with [JsonIgnore]
like this:
public class Build
{
public string Id { get; set; }
public string Name { get; set; }
public DateTime StartedAt { get; set; }
public DateTime FinishedAt { get; set; }
[Raven.Imports.Newtonsoft.Json.JsonIgnore]
//[Newtonsoft.Json.JsonIgnore] // for RavenDB 3 and up
public TimeSpan Duration { get { return StartedAt.Subtract(FinishedAt); }}
}
See more here: http://ravendb.net/docs/client-api/advanced/custom-serialization
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With