NHibernate: How to increment a column value without concurrency issues
问题 I have a database table CaseSymbol with columns: id , Symbol , LastNo It runs over ASP.NET MVC application. Multiple application instances can get the symbol and increment LastNo . CaseSymbol symbol = this.context.CurrentSession.Get<CaseSymbol>(id); symbol.LastNo++; Then it crashes obviously on following line: this.context.CurrentSession.Flush(); with following exception NHibernate.StaleObjectStateException: 'Row was updated or deleted by another transaction I tried to wrap it in transaction