TransactionScope
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
単語検索
|
最終更新
|
ヘルプ
]
開始行:
「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicros...
* 目次 [#p9eac4f1]
#contents
*概要 [#w9d80f60]
-TransactionScopeクラスは、2相コミットを実現するための.N...
内部的には、トランザクション マネージャ(TM)・リソース ...
-[[MS-DTC]]だけでなく、[[WS-Transaction>WCF]]などで使われ...
*詳細 [#j0f2099d]
**経緯 [#x3536ebe]
-ASP.NET 1.xでは、
--[[MS-DTC]]は[[Enterprise Services>MS-DTC#h37e6c88]]上か...
ビジネス プロセス・ビジネス コンポーネントなどのアプリケ...
--また、[[Enterprise Services>MS-DTC#h37e6c88]]アプリケー...
-このため、ASP.NET 2.0からは、
--上記のTransactionScopeクラスを利用することで、[[Enterpr...
ASP.NET上から簡単に2相コミットを利用できるように改善が図...
--なお、TransactionScopeクラスは、[[WCF]]の[[Binding>Bind...
こちらの実装は、ほぼ実用化に至らず、その後、[[WS-I等の標...
**動作確認用のサンプル プログラム(ASP.NET) [#f286d476]
2相コミットの動作確認用サンプル プログラムを用いて、Tran...
***SQL Server [#n96e60bd]
下記は、SQL Server用のデータ アクセス ライブラリである、~
SqlClientを利用した場合のサンプル コード。
private void Two_Phase_Commit(bool flag)
{
TransactionOptions txopt = new TransactionOptions();
txopt.IsolationLevel = System.Transactions.IsolationLe...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
using (TransactionScope scope = new TransactionScope(T...
{
using (SqlConnection con = new SqlConnection(@"Data ...
{
using (SqlCommand com = new SqlCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(bbb) value...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using (SqlConnection con = new SqlConnection(@"Data ...
{
using (SqlCommand com = new SqlCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(bbb) value...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
if (flag) // flag変数はコミット、ロールバックのテス...
{
scope.Complete();
}
else{ }
}
}
-分離レベルの選択が可能。Snapshot分離レベルは、SQLServer2...
-using (TransactionScope scopeのUsingステートメント範囲内...
(Usingステートメント コードブロックは、範囲外に出る際に...
-このため、Usingステートメントを使用しない実装をする際は...
-最後に、TransactionScope.Complete()メソッドを呼び出し、...
-TransactionScope.Complete()メソッドを呼び出さない状態でT...
***Oracle [#m90a6c30]
-下記は、Oracle用のデータ アクセス ライブラリである、Syst...
-実装を見てわかるとおり、ADO.NETの仕様に合わせ、APIのイン...
private void Two_Phase_Commit(bool flag)
{
TransactionOptions txopt = new TransactionOptions();
txopt.IsolationLevel = System.Transactions.IsolationLe...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
using (TransactionScope scope = new TransactionScope(T...
{
using (OracleConnection con = new OracleConnection(@...
{
using (OracleCommand com = new OracleCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(aaa, bbb) ...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using (OracleConnection con = new OracleConnection(@...
{
using (OracleCommand com = new OracleCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(aaa, bbb) ...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
if (flag) // flag変数はコミット、ロールバックのテス...
{
scope.Complete();
}
else{ }
}
}
----
Tags: [[:インフラストラクチャ]], [[:Windows]], [[:データ...
終了行:
「[[マイクロソフト系技術情報 Wiki>http://techinfoofmicros...
* 目次 [#p9eac4f1]
#contents
*概要 [#w9d80f60]
-TransactionScopeクラスは、2相コミットを実現するための.N...
内部的には、トランザクション マネージャ(TM)・リソース ...
-[[MS-DTC]]だけでなく、[[WS-Transaction>WCF]]などで使われ...
*詳細 [#j0f2099d]
**経緯 [#x3536ebe]
-ASP.NET 1.xでは、
--[[MS-DTC]]は[[Enterprise Services>MS-DTC#h37e6c88]]上か...
ビジネス プロセス・ビジネス コンポーネントなどのアプリケ...
--また、[[Enterprise Services>MS-DTC#h37e6c88]]アプリケー...
-このため、ASP.NET 2.0からは、
--上記のTransactionScopeクラスを利用することで、[[Enterpr...
ASP.NET上から簡単に2相コミットを利用できるように改善が図...
--なお、TransactionScopeクラスは、[[WCF]]の[[Binding>Bind...
こちらの実装は、ほぼ実用化に至らず、その後、[[WS-I等の標...
**動作確認用のサンプル プログラム(ASP.NET) [#f286d476]
2相コミットの動作確認用サンプル プログラムを用いて、Tran...
***SQL Server [#n96e60bd]
下記は、SQL Server用のデータ アクセス ライブラリである、~
SqlClientを利用した場合のサンプル コード。
private void Two_Phase_Commit(bool flag)
{
TransactionOptions txopt = new TransactionOptions();
txopt.IsolationLevel = System.Transactions.IsolationLe...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
using (TransactionScope scope = new TransactionScope(T...
{
using (SqlConnection con = new SqlConnection(@"Data ...
{
using (SqlCommand com = new SqlCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(bbb) value...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using (SqlConnection con = new SqlConnection(@"Data ...
{
using (SqlCommand com = new SqlCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(bbb) value...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
if (flag) // flag変数はコミット、ロールバックのテス...
{
scope.Complete();
}
else{ }
}
}
-分離レベルの選択が可能。Snapshot分離レベルは、SQLServer2...
-using (TransactionScope scopeのUsingステートメント範囲内...
(Usingステートメント コードブロックは、範囲外に出る際に...
-このため、Usingステートメントを使用しない実装をする際は...
-最後に、TransactionScope.Complete()メソッドを呼び出し、...
-TransactionScope.Complete()メソッドを呼び出さない状態でT...
***Oracle [#m90a6c30]
-下記は、Oracle用のデータ アクセス ライブラリである、Syst...
-実装を見てわかるとおり、ADO.NETの仕様に合わせ、APIのイン...
private void Two_Phase_Commit(bool flag)
{
TransactionOptions txopt = new TransactionOptions();
txopt.IsolationLevel = System.Transactions.IsolationLe...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
//txopt.IsolationLevel = System.Transactions.Isolation...
using (TransactionScope scope = new TransactionScope(T...
{
using (OracleConnection con = new OracleConnection(@...
{
using (OracleCommand com = new OracleCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(aaa, bbb) ...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
using (OracleConnection con = new OracleConnection(@...
{
using (OracleCommand com = new OracleCommand())
{
com.Connection = con;
com.CommandText = "insert into table1(aaa, bbb) ...
try
{
con.Open();
com.ExecuteNonQuery();
}
finally
{
con.Close();
}
}
}
if (flag) // flag変数はコミット、ロールバックのテス...
{
scope.Complete();
}
else{ }
}
}
----
Tags: [[:インフラストラクチャ]], [[:Windows]], [[:データ...
ページ名: