RavenDb - 由于属性名称重复而无法存储
我正在尝试在 Raven 中存储文档 - 但子类隐藏了基类上的属性 - 名称相同但类型不同。当我尝试保存它时,出现此错误:
““帐户”上已存在名为“用户”的成员。使用 JsonPropertyAttribute 指定另一个名称
但是,该类是密封的,我不拥有它或不能拥有它我还有什么选择吗?
I'm trying to store a document in Raven - but a subclass hides a property on a base class - same name but different type. When I try and save it, I get this error:
"A member with the name 'User' already exists on 'Account'. Use the JsonPropertyAttribute to specify another name
However, the class is sealed and I don't own it or cannot extend it. Do I have any options at all?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您可以修改尝试存储的类,则可以设置 JsonContract(在 DocumentConventions 上)并修改它从那里序列化的方式。
If you can modify the class that you are trying to store, you can set the JsonContract (on the DocumentConventions) and modify how it gets serialized from there.