2017-07-30 35 views
0

我试图了解实体框架乐观并发,我无法改写了最新的一个变化。请看看代码。保存更改,尽管DbUpdateConcurrencyException

var x = a.users.Where<users>(s => s.id == 4).First<users>(); 
x.name = "xxxx"; 
try{ 
     a.SaveChanges(); 
} 
catch(DbUpdateConcurrencyException ex){ 
    message("Overwrite other changes ? yes or no"); 
    if(yes){ 
     // overwrite the entity values with mine in the db 
    }    
} 

基本上当记录得到了由其他用户更新,管理员会看变化,他必须覆盖旧值。我怎么做?任何帮助是极大的赞赏。

回答

0

并发的例外是在特定的交易,如果你想拥有管理员干预之间,你需要到一个地步,你可以存储交易数据,然后管理员可以决定要更新的一个。