有效的自定义天蓝色表存储实体序列化?
有没有办法有效地自定义天蓝色表存储实体的序列化?我已经阅读了许多有关 ReadingEntity/WritingEntity 事件的帖子/主题,但我认为这不足以满足我的需要。我希望我的实体支持:
- 枚举类型属性;
- 我已经测试了很多选项,更多选项对我不起作用,我收到异常(状态代码 500),未调用 ReadingEntity/WritingEntity 事件处理程序,并且实体未持久化。那么,事件处理程序方法不适用于此问题。
- 只读属性;
- 在我的测试中,我收到异常(“封闭类型 System.String 没有相应的 S 可设置属性。”),但实体被持久化,那么也许我可以忽略该异常。 WriteEntity 事件处理程序被调用,但我认为我可能无法对异常做出任何处理。最大的问题是,当我加载对象时,没有调用 ReadingEntity 事件处理程序,那么我无法解决这个问题。那么,事件处理程序方法不适用于此问题。
- 瞬态/计算属性;
- 我没有测试过,但我认为可以使用事件处理程序方法来实现,只需删除writingEntity 事件处理程序中的属性即可。
- PartitionKey/RowKey 元素的自定义名称;
- 我没有测试过,但我认为可以使用事件处理程序方法来实现。我可以在实体类中使用 DataServiceEntity 属性,并在writingEntity 事件处理程序中将自定义名称重命名为所需名称。
- 没有公共默认构造函数。
- 好的,这在我的测试中效果很好。
好吧,问题 1 和 2 对我来说仍然是一个大问题,有人知道我如何实现所有 5 个目标吗?
谢谢.. 此致..
Is there any way to effectively customize the serialization of an azure table storage entity? I already read many posts/topics about ReadingEntity/WritingEntity events, but I think that isn't sufficient for what I need. I want that my entities support:
- Enum types properties;
- I have tested many options, more don't work for me, I receive an exception (status code 500), the ReadingEntity/WritingEntity event handlers aren't called and the entity is not persisted. Then, the event handlers approach doesn't work for this issue.
- Read-only properties;
- In my test, I receive the exception ("The closed type System.String does not have a corresponding S settable property."), but the entity was persisted, then maybe I can just ignore the exception. The WritingEntity event handler is called, but I think that I maybe can't make nohting about the exception. The big problem is that the ReadingEntity event handler isn't called when I load the object, then I can't resolve this issue. Then, the event handlers approach doesn't work for this issue.
- Transient/calculated properties;
- I have not tested, but I think that can be made with the event handlers approach, just remove property in the WritingEntity event handler.
- Custom names to PartitionKey/RowKey elements;
- I don't have tested, but I think that can be made with the event handlers approach. I can use DataServiceEntity attribute in my entity class and make the rename, from my custom names to required names, in WritingEntity event handler.
- Don't have a public default constructor.
- Ok, this has worked fine in my test.
Well, the issues 1 and 2 remain a big problem for me, anybody has any idea for I accomplish all 5 goals?
Thank's..
Best regards..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议使用 Lokad.Cloud 的 FatEntity 方法。根据我们的经验,它更简单、更高效。
I would suggest the FatEntity approach of Lokad.Cloud. It's simpler and more efficient in our experience.