public class RavenDbRegistry : Registry { public RavenDbRegistry() { var documentStore = new DocumentStore { ConnectionStringName = "RavenDB", Conventions = { IdentityPartsSeparator = "-", JsonContractResolver = new PrivatePropertySetterResolver(), CustomizeJsonSerializer = serializer => { serializer.TypeNameHandling = TypeNameHandling.Auto; serializer.ObjectCreationHandling = ObjectCreationHandling.Replace; }, DefaultQueryingConsistency = ConsistencyOptions.AlwaysWaitForNonStaleResultsAsOfLastWrite, } }; documentStore.Initialize(); For<IDocumentStore>().Singleton().Use(documentStore); For<IDocumentSession>().Use(ctx => ctx.GetInstance<IDocumentStore>().OpenSession()); } }
I am having trouble saving instances of an object using RavenDB.Client version 3.0.3690 when I have not had this problem previously. The class definition of the type I am trying to save is as follows:public class DedPersistentModel : PersistentModel { public EquipmentName Name { get; private set; } public AggregateId CommsEquipmentId { get; private set; } public IEnumerable<EquipmentAlarmType> AlarmTypes { get; private set; } public DedPersistentModel() { Name = new EquipmentName("Default Ded"); AggregateId = new AggregateId(new Guid()); CommsEquipmentId = new AggregateId(new Guid()); AlarmTypes = new List<EquipmentAlarmType>(); } ... Unrelated methods }
public class PrivatePropertySetterResolver : DefaultContractResolver
{
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
{
var prop = base.CreateProperty(member, memberSerialization);
if (!prop.Writable)
{
var property = member as PropertyInfo;
if (property != null)
{
var hasPrivateSetter = property.GetSetMethod(true) != null;
prop.Writable = hasPrivateSetter;
}
}
return prop;
}
}
public class EquipmentAlarmType : ValueObject<EquipmentAlarmType> { public EquipmentAlarmType() { AlarmText = new EquipmentAlarmText("Alarm raised"); RestoreText = new EquipmentAlarmText("Alarm restored"); AlarmCategory = new EquipmentAlarmCategory(3); RestoreCategory = new EquipmentAlarmCategory(3); } public EquipmentAlarmType(string alarmText, string restoreText, int alarmCategory, int restoreCategory, string alarmName) { try { AlarmText = new EquipmentAlarmText(alarmText); RestoreText = new EquipmentAlarmText(restoreText); AlarmCategory = new EquipmentAlarmCategory(alarmCategory); RestoreCategory = new EquipmentAlarmCategory(restoreCategory); AlarmName = new EquipmentAlarmName(alarmName); } catch (ArgumentException) { throw; } } public EquipmentAlarmText AlarmText { get; private set; } public EquipmentAlarmText RestoreText { get; private set; } public EquipmentAlarmCategory AlarmCategory { get; private set; } public EquipmentAlarmCategory RestoreCategory { get; private set; } public EquipmentAlarmName AlarmName { get; protected set; } }
What do I need to do to resolve this issue?
Thanks.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
Office: +972-4-622-7811 l Fax: +972-153-4-622-7811
--
You received this message because you are subscribed to the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ravendb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You have a converter somewhere here, right?Basically, eventually you are calling JsonWriter.WriteValue( object ) - and that isn't usually supported.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969
--
You received this message because you are subscribed to a topic in the Google Groups "RavenDB - 2nd generation document database" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ravendb/UgkGEm_F9AY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ravendb+u...@googlegroups.com.
Hibernating Rhinos Ltd
Oren Eini l CEO l Mobile: + 972-52-548-6969