問題描述
在 .NET 中使用 MongoDB 和 NoRM.
Playing around with MongoDB and NoRM in .NET.
讓我困惑的事情 - 沒有交易
(不能只是告訴 MongoConnection.Begin/EndTransaction
或類似的東西.
Thing that confused me - there are no transactions
(can't just tell MongoConnection.Begin/EndTransaction
or something like that).
我想使用工作單元模式并在出現故障時回滾更改.
I want to use Unit of work pattern and rollback changes in case something fails.
是否還有一種干凈的方法可以使用 ITransaction 豐富我的存儲庫?
Is there still a clean way how to enrich my repository with ITransaction?
推薦答案
MongoDB 不支持復雜的多文檔事務.如果這是您絕對需要的東西,它可能不太適合您.
MongoDB doesn't support complex multi-document transactions. If that is something you absolutely need it probably isn't a great fit for you.
但是,在大多數情況下,我們發現不需要復雜的事務.MongoDB 中的所有操作在單個文檔上都是原子的,我們支持很好的 更新修飾符,它使許多需要事務的操作變得容易(且快速).
In most cases, however, we've found that complex transactions aren't a requirement. All operations in MongoDB are atomic on a single document, and we support nice update modifiers, which make a lot of operations that would need a transaction easy to implement (and fast).
這篇關于MongoDB 交易?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!