使用 NHibernate 映射具有由模糊字段支持的关系的实体
这里还有一个关于 NHibernate 的问题。 这个问题很可能没有理想的答案,但仍然让我们尝试一下。
我目前正在全力以赴地使用 NHibernate 将域模型映射到数据库上。该领域模型来自一个严重混淆的框架。 (并不是说我之前已经处理过很多混淆的代码,但是在大多数地方,这个代码既不能被 Reflector 翻译,也不能被 Resharper 翻译。)
一切都或多或少地顺利,直到我面对一个需要多对多的实体。 - 由属性表示的一个关系,没有带有模糊支持字段的设置器。
- 是否可以以某种方式引用这个混淆的字段?一个非常特殊的
IPropertyAccessor
? - 如果没有,我如何加载一个完全构建的实体?注入相关对象的唯一选择是使用接受它的构造函数。但是在实例化正在加载的实体时,除了密钥之外,
IInstantiator
和IInterceptor
都没有任何数据。还有其他适合我需要的扩展点吗?
And here goes yet another question on NHibernate.
This one most likely doesn't have a desired answer, but still - let's give it a try.
I'm currently putting all the efforts into mapping a domain model onto the database using NHibernate. This domain model comes from a framework which is heavily obfuscated. (Not that I have worked a lot with obfuscated code before, but this one in most of the places can be translated neither by Reflector, nor by Resharper.)
Everything went more or less fine until I faced an entity with a required many-to-one relationship represented by a property with no setter with obfuscated backed field.
- Is it possible to reference this obfuscated field somehow? A very special
IPropertyAccessor
? - If not, how can I load a fully constructed entity? The only option to inject a related object is by using a constructor that accepts it. But at the time of instantiating of an entity being loaded, neither
IInstantiator
norIInterceptor
has any data of it apart from the key. Any other extension points that suit my need?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
要允许 NHibernate 访问您的字段而不是属性,您可以在映射中使用它:
To allow NHibernate to access your field instead of property you can use this in your mappings: