使用NoRM在MongoDB的一个集合中存储多种类型的对象
MongoDB 是无模式的。因此,从技术上讲,我可以在一个集合中存储任意数量的不同类型。目前我们需要在一个集合中存储继承自同一基类的多个对象。使用 NoRM 可以实现这一点吗?
例如,我们有一个Person集合,但是这个person集合包含继承自Person的Fathers和继承自Person的Mothers等。我们需要存储它们的Father特定和Mother特定属性,然后在将它们拉出时Mongo,我们想要创建适当的对象。 NoRM 可能实现这样的事情吗?
MongoDB is schema-less. So, I can technically store any number of different types within one collection. We currently have the need to store multiple objects that inherit from the same base class in one collection. Is this possible using NoRM?
For example, we have a Person collection, but this person collection contains Fathers that inherit from Person and Mothers that inherit from Person, etc. We need their Father-specific and Mother-specific properties to be stored and then when they are pulled out of Mongo, we want the appropriate object created. Is such a thing possible with NoRM?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道我来晚了这个问题,但我正在阅读一些相关问题...
我不知道 Andrew 对 NoRM 的支持状态的看法是否正确,但确实它似乎不活跃。不过,有一种方法可以使用 10gen MongoDB C# 驱动程序来完成您想做的事情。
这是链接。 这适用于您所在的位置类之间的多态关系。
I know I am coming along late to this question, but I was reading some related questions....
I don't know if Andrew is right about NoRM's support status, but it is true that it seems inactive. However there is a way you can do what you want to do using the 10gen MongoDB C# driver.
Here's the link. This works where you have a polymorphic relationship between your classes.