Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set entire mapping to read only in NHibernate 3.2 mapping-by-code?

I'm just getting up to speed with NHibernate 3.2 and its "mapping by code" feature, and migrating our Fluent mapping over to it. Is there an equivalent of the fluent "ReadOnly();" function, to make the entire mapping read only? Thanks in advance.

like image 268
Andrew Stephens Avatar asked Oct 06 '11 08:10

Andrew Stephens


2 Answers

Use Mutable(false) in the mapping.

Read this post for corresponding hbm file mapping from where I could infer this.

http://davybrion.com/blog/2007/08/read-only-data-in-nhibernate/

like image 94
dreamerkumar Avatar answered Sep 25 '22 14:09

dreamerkumar


Use PropertyMapper action to define access style:

public class EntityMapping : ClassMapping<Entity>
{
     public EntityMapping()
     {
         Id(m => m.Id, map => map.Generator(Generators.HighLow));
         Property(m => m.Name, map => map.Access(Accessor.ReadOnly));
     }
}
like image 44
cylon-v Avatar answered Sep 26 '22 14:09

cylon-v