且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

与NHibernate的设计问题域模型

更新时间:2022-06-12 05:17:57

您可以在映射的IsBlocked属性定义字段访问策略。基本上,你会说NHibernate的使用底层的私有字段(_isBlocked),而不是财产,因此,在IsBlocked财产您的setter逻辑将不会被执行。

You can define field access strategy in your mapping for the IsBlocked property. Basically, you would say to NHibernate to use underlying private field (_isBlocked) instead of property and hence, your setter logic in IsBlocked property won't be executed.

这太问题对接入战略的一个很好的答案。

This SO question has a good answer on access strategies.

NHibernate的官方的文档

Official NHibernate documentation.

如果您在使用功能NHibernate映射,这是你如何定义它:

If you are using Fluent NHibernate for mapping, this is how you could define it:

Map(x => x.IsBlocked).Access.CamelCaseField(Prefix.Underscore);