How do I tell Fluent NHibernate to ignore specific properties without automapping?

时光毁灭记忆、已成空白 提交于 2019-12-12 13:42:02

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/8583912/how-do-i-tell-fluent-nhibernate-to-ignore-specific-properties-without-automappin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!