title: NHibernate + ViewModel +MVC + Optimistic lock
body: <p>Ok we have the following senario, but how do you do <a href="http://martinfowler.com/eaaCatalog/optimisticOfflineLock.html" rel="nofollow">Optimistic Locking</a></p>
  
  <p>we have a Customer Class</p>
  
  <ul>
  <li>Name</li>
  <li>Address</li>
  <li>Version</li>
  </ul>
  
  <p>The version is a collision varible (int) which when the row is edited the version will increase by 1.</p>
  
  <p>Now we have Martin who open Customer 129, as with a view model the model object is flattened into the View Model then passed onto a Customer Edit Screen.</p>
  
  <p>David in the mean time also opens the Customer 129 for edit, changes the name and saves.</p>
  
  <p>Martin, who was still editing the customer (now an old version), goes to save his changes, at this point I would hope to see an Lock error to be thrown</p>
  
  <p>the Question is how do you handle Optimistic locking with NH (using FluentNHibernate for mappings), would you do</p>
  
  <ul>
  <li>have to push the verion number into the ViewModel? then when it has been submitted with an update, load in the current Model object and check the version Numbers</li>
  <li>Or is threre a better way (I know NH would do versioning if I Load, Edit and Update in the same session)</li>
  </ul>
  
  <p>one extra thing, this scenario will be used on a farm, not sharing a cache</p>
  
  <p>many thanks in advance</p>