交易回滚实体模型 [英] Transaction Roll Back in Entity Model

查看:72
本文介绍了交易回滚实体模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

   我们正在使用MVVM模式和EF创建会计软件。 在某一点当我们尝试将记录保存到表时,我们还将调用存储过程来更新其他表。当其中一个操作失败时,我们不希望
更新其他表。因此,当任何Save操作失败时,我们想要进行Transction Roll Back。在其他类型的项目中,我们可以使用Transaction Scope,但Silverlight不允许我们添加System.Transaction dll。如何在Silverlight项目中完成这个

    We are creating a Accounting SoftWare using MVVM pattern and EF.  At one point When we try to save a record to a table, we will also call stored procedure to update other tables. When one of the Operation fails then we do not want to update the other tables. So we want to do Transction Roll Back, when any of the Save operation Fails. In other type of projects , we can use Transaction Scope, But silverlight is not allowing us to add the System.Transaction dll. How to accomplish this in Silverlight project?

请帮助我们解决这个问题。

Kindly help us to solve this issue.

Rds,

Parameswari

Parameswari

 

推荐答案

正如你所说的那样你正在使用MVVM + EF,然后在上下文中保留你的更改,然后在完成所有工作之后再使用context.savechanges / submit更改,如果成功,那么每件事都会被保存。如果它失败那么它会恢复自动更改
,或者您可以使用上次保存的数据刷新上下文。
As you said that you are using MVVM + EF then keep your changes in the context and after doing all the stuff then use context.savechanges/submit changes if it succeed then every thing will be saved .if it fails then it would revert changes automatically or you can refresh your context with the last saved data.


这篇关于交易回滚实体模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆