Question

I'm storing objects in my saga data that have properties that should be ignored during serialization and deserialization. I've tried marking these properties with both [NonSerialized] and [JsonIgnore] (and annotating the classes with [DataContract] and not making those properties [DataMember]...) and nothing seems to do the trick. No matter what I do, when NServiceBus calls Json.NET to persist the saga data all the properties get serialized. I've also tried implementing a custom JsonConverter for the objects in question, and that gets ignored as well (yes, I'm annotating the object type with [JsonConverter(typeof(MyConverter))]...)

Is there a way to get saga persistence to ignore a property in an object contained within the saga data? For reference, I'm using NServiceBus 3.2.7, Json.NET 4.5.7, and RavenDB build 960. The bus is configured to use RavenDB persistence and saga persistence.

Was it helpful?

Solution

NServiceBus internalize both the raven client and json.net. That is why those attributes don't work(they are essentially different types since we merge with the internal flag). The workaround is to use the core only version of nsb that isn't merged. That said I'm curious why you need those extra properties?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top