NHibernate : map to fields or properties?

后端 未结 7 1188
傲寒
傲寒 2021-01-02 00:55

When you create your mapping files, do you map your properties to fields or properties :



        
相关标签:
7条回答
  • 2021-01-02 01:57

    I tend to agree with the answers above. Generally, map to properties for almost everything, then map to fields for collection setters.
    The only other place you'd want to map to fields is when you have something:

    public class AuditableEntity
    {
       /*...*/
       DateTime creationDate = DateTime.Now;
       /*...*/
       public DateTime CreationDate { get { return creationDate; } }
    }
    
    0 讨论(0)
提交回复
热议问题