我已经阅读了有关为什么强烈建议在NH的读取操作中使用事务的文档和说明。但是,我还没有完全“购买”它。有人可以告诉我我已经做过的事,而不只是告诉我RTFM吗? ;)
Best Answer-推荐答案 strong>
This post from one of the authors可能有您的答案:
Even if we are only reading data, we
want to use a transaction, because
using a transaction ensure that we get
a consistent result from the database.
NHibernate assume that all access to
the database is done under a
transaction, and strongly discourage
any use of the session without a
transaction.
Leaving aside the safety issue of
working with transactions, the
assumption that transactions are
costly and we need to optimize them is
a false one. As already mentioned,
databases are always running in
transaction. And databases have been
heavily optimized to work with
transactions. The question is whatever
this is per statement or per batch.
There is some amount of work that need
to be done to create and dispose a
transaction, and having to do it per
statement is actually more costly than
doing it per batch.
关于c# - NHibernate读取交易,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/1657465/
|