问题描述
我正在使用流利NHibernate映射出一个现有的数据库。出于这个原因 - 自动映射不是我的选择。我如何告诉NHibernate不映射某些属性?其中许多是只读的,而其他的则不需要被其他原因持久化。
我在VB.Net中写这个。
我得到了典型的错误信息:
以下类型不能用作代理
...应该是public / protected virtual或protected internal我有意不让我的对象Overridable(相当于C#中的虚拟),因为我不希望NHibernate触摸它们。
b
我该如何做到这一点?
所有属性和方法必须被覆盖才能使NHibernate创建动态代理,包括未映射的属性。这并不意味着NHibernate映射你的只读属性,它只是要求它们被覆盖,以便它可以生成类的代理。 解释了这一要求。 p>
I am using Fluent NHibernate to map out an existing database. For this reason - automapping isn't an option for me.
How do I tell NHibernate not to map certain properties? Many of them are read-only, and the others do not need to be persisted for other reasons.
I am writing this in VB.Net.
I get the typical error message:"The following types may not be used as proxies... should be 'public/protected virtual' or 'protected internal virtual'"
I have purposely not made my objects Overridable (equivalent to virtual in C#) because I do not want NHibernate to touch them.
How can I achieve this?
All properties and methods must be overridable in order for NHibernate to create dynamic proxies, including unmapped properties. This does not imply that NHibernate is mapping your read-only properties, it just requires them to be overridable so that it can generate a proxy of the class. This article explains the requirement.
这篇关于我如何告诉流利的NHibernate没有自动映射忽略特定的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!