在实体框架中检索身份值并且仍然能够回滚
我想在使用实体框架在数据库中插入行后检索标识列值。所以我必须调用 context.savechanges() ,但如果在更新行和检索标识列值后出现问题,我想完全回滚。
在 EF 4.0 中这是否可能? 我知道如何检索标识列值,并且通过回滚我的意思是应该删除插入的行。 我的身份列是自动生成的 bigint 类型。
I want to retrieve the Identity column value after inserting a row in DB using entity framework. So I have to call context.savechanges()
, but in case something goes wrong after updating row and retrieving identity column value, I want to to rollback completely.
Is this possible somehow in EF 4.0.?
I know how to retrieve identity column value and by rollback I mean that the inserted row should be deleted.
My identity column is an autogenerated bigint type.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用
TransactionScope
怎么样?如果不调用
Complete
事务将会回滚。What about using
TransactionScope
If you do not call
Complete
transaction will rollback.