Can NHibernate set non-public properties?

Is it possible to set NHibernate to load / save a non-public class property? For example, I may have an Item class as follows.

public class Item { public int ItemID {get; set;} public string Name{get; set;} } 

With the following display:

 <class name="RCL.Item" table="Items"> <id name="ItemID" type="Int32" column="ItemID"> <generator class="native"/> </id> <property name="Author" /> </class> 

However, I really do not want users of my Item class to be able to change the ItemID field. Can I restrict access to the ItemID accessory kit? If so, what should I install? Private, secure, internal, secure internal?

+4
source share
1 answer

From the NHibernate tutorial:

Properties do not have to be declared public - NHibernate can save a property using internal, secure, secure internal or private visibility.

Just set ItemID to private

+10
source

All Articles