nhibernatefluent-nhibernate

FluentNHibernate: CamelCaseField vs ReadOnlyPropertyThroughCamelCaseField


Given the following class:

public class User {
  private IList<ActivationToken> _activationTokens;
  public virtual IReadOnlyList<ActivationToken> ActivationTokens => _activationTokens.AsReadOnly();
}

what should the correct FluentNHibernate mapping be and why?

HasMany( x => x.ActivationTokens ).Access.CamelCaseField( Prefix.Underscore );

or

HasMany( x => x.ActivationTokens ).Access.ReadOnlyPropertyThroughCamelCaseField( Prefix.Underscore );

Tnx


Solution

  • The correct mapping is:

    HasMany(x => x.ActivationTokens) .Access.ReadOnlyPropertyThroughCamelCaseField(Prefix.Underscore); enter code here

    Reason: