Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// <summary>
- /// This reloads a model from a (new) context, this serves to different
- /// porpouses.
- ///
- /// First we need a model class attached to a current context to perform
- /// many operations (navigating relations, delete, edit etc..)
- ///
- /// Second we need to check if the model object was not deleted from the
- /// database in the meantime.
- ///
- /// Third we will do some concurrency check. If an object in the database
- /// was modified elsewhere, we won't do any operation and raise a ConcurrentChangeException
- ///
- /// I'm not completely entirely sure that this is what is required for Concurrency
- /// Management, some parts of the specifications seems to imply that like
- ///
- /// "Any detected attempt to save an entity on the DB which has been concurrently modified must be communicated throwing ConcurrentChangeException"
- ///
- /// some thread on the other hand seems to deny this, like
- ///
- /// http://dibris.aulaweb.unige.it/mod/forum/discuss.php?d=5679
- /// "non ci sono test automatici per il comportamento concorrente (e non ne posso fare se testo attraverso l'interfaccia)"
- ///
- /// http://dibris.aulaweb.unige.it/mod/forum/discuss.php?d=5631
- /// "Qualsiasi sistema ragionevole che usa la componente non dovrebbe mai avere due oggetti distinti che rappresentano la
- /// stessa entità. Pertanto, non ci si dovrebbe mai trovare nella situazione di avere due oggetti A e B che rappresentano entrambi
- /// la stessa entità E e voler accedere a metodo/proprietà su A dopo aver invocato Delete su B. Per questa ragione la specifica non
- /// dettaglia bene che cosa dovrebbe succedere (perché non dovrebbe succedere)
- ///
- /// </summary>
- /// <param name="context"></param>
- public virtual void RefreshModel(AuctionContext context)
- {
- var newModel = this.GetModel(context);
- if (((IConcurrencyEnabled)this.Model).RowVersion < ((IConcurrencyEnabled)newModel).RowVersion)
- {
- throw new ConcurrentChangeException();
- }
- else
- {
- this.Model = newModel;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment