Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configure Fluent NHibernate mapping to allow INSERT only?

I'm moving a project from SubSonic to NHibernate and am using Fluent NHibernate to perform all of our mapping. Our db schema is pretty straight forward and most of our cases appear thus far to be well illustrated by different blog posts and sample code that's available.

One thing that I'm unable to figure out however is the ability to Map a column so that its value is only allowed to be set on the initial INSERT of the data. It's a generated value on our app tier, and once inserted, we don't want to allow it to be updated any further.

I tried the obvious (but wrong)

Map(x => Foo).ReadOnly()

What would be the appropriate function chain to accomplish what I'm after?

like image 780
bakasan Avatar asked Feb 19 '10 03:02

bakasan


1 Answers

After much experimentation--

Map(u => Foo).Not.Update();

Appears to be doing what I desire--but I'd love if more experienced hands chimed in to confirm that my interpretation of the results is accurate. i'd hate to mark this as the answer and inadvertently send future visitors down the wrong path.

like image 164
bakasan Avatar answered Oct 23 '22 12:10

bakasan