开发者

Data Access Application Block 4.1 and Transactions

Can anyone please tell me what is the prefered way to manage transaction when using Enterprise Library's DAAB (version 4.1)? I was thinking about

Database NewDb = DatabaseFactory.CreateDatabase();
DBC开发者_如何学Command NewCmd = NewDb.GetStoredProcCommand("SProcName");

/* Add parameters here. */

using (TransactionScope NewTrans = new TransactionScope())
{
    NewDb.ExecuteNonQuery(NewCmd);
    NewTrans.Complete()
}

but I don't know if I will be doing the right way.


TransactionScope is the preferred way to do transactional work in Enterprise Library. Your example is fine.

You do have the option to do manual transaction management - that's primarily in there for backwards compatibilty for older Entlib code.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜