저는 TransactionScope를 처음 사용합니다. 나는 단지 아래 코드에서 내가하고있는 일이 올바른지 확인하고 싶다.EF4에서 TransactionScope에 대한 도움말
private void DoSomeWork()
{
using (var context = new MyEntities())
using (TransactionScope scope = new TransactionScope())
{
context.Connection.Open();
int ID = context.CallUpdateStoredProc();
RecursiveDelete((EntityConnection)context.Connection, ID);
context.Connection.Close();
scope.Complete();
}
}
private void RecursiveDelete(EntityConnection connection,int someID)
{
using (var context = new MyEntities(connection))
{
var UpdatedLinks = context.CallSaveStoredProc(someID).ToList();
foreach (int UpdatedLink in UpdatedLinks)
{
RecursiveDelete(connection,UpdatedLink);
}
}
}