如何验证SubmitChanges()是否有效 [英] How do verify that SubmitChanges() is work or not

查看:117
本文介绍了如何验证SubmitChanges()是否有效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何验证LINQ SubmitChanges()是否适用于插入和更新?该方法不返回bool或int值。

How do you verify that LINQ SubmitChanges() worked for inserts and updates? The method doesn't return a bool or int value.

推荐答案

try catch是检查这些内容的最佳方法。
try catch is the best thing to check these things.


一个很好的问题,看起来你必须执行手动检查。



注意: SubmitChanges()启动一个事务,如果在执行SubmitChanges时发生异常,它将回滚。

但是,这不会回滚内存中的更改或DataContext跟踪的更改;这些更改需要手动回滚。
A good question, however, it looks like you will have to perform a manual check.

Note: SubmitChanges() starts a transaction and will roll back if an exception occurs while SubmitChanges is executing.
This does not, however, roll back the changes in memory or tracked by the DataContext; those changes will need to be rolled back manually.


你正在使用那个交易?


这篇关于如何验证SubmitChanges()是否有效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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