Wednesday, June 27, 2018

NHibernate Immutable Types

To prevent that changes to your objects end up accidently into your database, NHibernate supports type immutability.

This is something you can set at the ClassMap level(if you are using the mapping by code):

With Fluent Nhibernate, you have to use the ReadOnly property:

Remark: Using this property makes sure that the objects that you retrieve are read-only, so you cannot UPDATE them. However, it does NOT prevent the creation of new records or even the deletion of existing records in the database.

No comments: