IDocumentSession.SaveChanges() 与事务
在调用 SaveChanges
之前,raven 客户端 (IDocumentSession
) 不会向服务器发送任何内容。所以它可以被视为一个 UnitOfWork 实现,对吗?
我是否正确地认为 SaveChanges 和 Transaction.Commit 之间的唯一区别是,如果提交期间出现失败,后者会回滚所有更改?
The raven client (IDocumentSession
) doesn't send anything to the server until SaveChanges
is called. So it could be considered as a UnitOfWork implementation, right?
Am I correct in thinking that the only difference between SaveChanges
and Transaction.Commit
is that the latter rolls back all changes if something failed during the commit?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您执行单个操作,则无需使用显式事务,因为
SaveChanges
会导致隐式事务。如果您使用
System.Transactions
,则可以执行多个操作,即使用同一事务执行多个SaveChanges
。 Raven 将使用请求标头通过 http 管理事务。在文档中阅读更多内容:http://ravendb.net/documentation/docs-api-transactions
If you are doing a single operation, there is no need to use an explicit transaction since the
SaveChanges
results in a implicit transaction.If you make use of
System.Transactions
, you can perform multiple operations, ie multipleSaveChanges
using the same transaction. Raven will manage the transactions over http using a request header.Read more in the docs: http://ravendb.net/documentation/docs-api-transactions
SaveChanges()
在事务中操作,因此如果您正在修改多个文档,则所有文档都将被保存,或者都不保存。还支持
System.Transactions
,但通常不需要。SaveChanges()
operate in a transaction, so if you are modifying multiple documents, all of them would be saved, or none would.Also support
System.Transactions
, but usually it is not needed.