.netnhibernatefluent-nhibernateautomatic-propertiesbacking-field

What is the use case for Access.BackingField in Fluent NHibernate?


The documentation for Access.BackingField() indicates that this:

Sets the access-strategy to use the backing-field of an auto-property.

I understand that auto-properties get compiled with backing fields, but if the property is by definition a vanilla getter/setter, what advantage is garnered by going to the backing field directly versus using the setter (i.e. using the FNH defaults).

The only thing I can think of is that one might want the mapping to break if someone later adds logic to the setter.

What am I missing?


Solution

  • Ah, I think I found the answer here.

    Use the backing field if the auto-property has a private accessor.