0

I have done simple My sql transactions. But Is there a way to make transactions through c# ?

Example:

Insert all rows from a file or never insert anything.

Are there any examples or directions for doing this in c#? I have only done single query execution through parametrized c# syntax. writing a delete query I think is an overkill and does not suit my needs.

4

1 に答える 1

3

そうです。

MySQL で Entity Framework を使用している場合、SaveChanges() はトランザクション内で実行されます。すべてが成功するか、すべてが一緒に失敗します (必要に応じて、TransactionScopeを使用してその側面をより細かく制御できます)。

ADO.Net を使用すると、次のようにTransactionScopeを使用できます。

https://stackoverflow.com/a/3321030/141172

TransactionScope は DataTable でも動作します

http://www.codingbeaver.com/myblog/2010/02/19/update-datatable-in-transaction/

于 2013-02-22T17:54:46.097 に答える