开发者

property Access strategies in nhibernate

开发者 https://www.devze.com 2022-12-21 03:02 出处:网络
What are the access strategies that I can use in the attribute access of the nhibe开发者_高级运维rnate xml?

What are the access strategies that I can use in the attribute access of the nhibe开发者_高级运维rnate xml?

Can someone point me the possible values to be used in it?

A nice tutorial would be very appreciated.

Thanks


Property Access strategies are described in the reference documentation under 5.1.9. Property.

The access attribute lets you control how NHibernate will access the value of the property at runtime. The value of the access attribute should be text formatted as access-strategy.naming-strategy. The .naming-strategy is not always required.

Access strategy can be one of:

  • property The default implementation. NHibernate uses the get/set accessors of the property. No naming strategy should be used with this access strategy because the value of the name attribute is the name of the property.
  • field NHibernate will access the field directly. NHibernate uses the value of the name attribute as the name of the field. If you want the name of the property and not the field to be what the consumers of your API use with HQL, then a naming strategy is needed.
  • nosetter NHibernate will access the field directly when setting the value and will use the Property when getting the value. A naming strategy is required because NHibernate uses the value of the name attribute as the property name and needs to be told what the name of the field is.
  • ClassName If NHibernate's built in access strategies are not what is needed for your situation then you can build your own by implementing the interface NHibernate.Property.IPropertyAccessor. The value of the access attribute should be an assembly-qualified name that can be loaded with Activator.CreateInstance(string assemblyQualifiedName).

Naming strategy can be one of:

  • camelcase The name attribute is converted to camel case to find the field.
  • camelcase-underscore The name attribute is converted to camel case and prefixed with an underscore to find the field.
  • lowercase The name attribute is converted to lower case to find the Field.
  • lowercase-underscore The name attribute is converted to lower case and prefixed with an underscore to find the Field.
  • pascalcase-underscore The name attribute is prefixed with an underscore to find the field.
  • pascalcase-m The name attribute is prefixed with the character m to find the field
  • pascalcase-m-underscore The name attribute is prefixed with the character m and an underscore to find the field.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号