【发布时间】:2013-09-10 05:16:12
【问题描述】:
给定以下代码,DoDatabaseOperation() 和 MethodAnotherContext() 方法会包含在事务中吗?请注意,context1 和 context2 的类型相同,并且正在处理连接字符串。
using (EFContext context1 = new EFContext())
{
using (TransactionScope transScope = new TransactionScope())
{
DoDatabaseOperation(context1); // Call context1.functionImport to update records
while (....)
{
.................A lot of code............
context1.SaveChanges();
MethodAnotherContext();
}
transScope.complete();
}
}
public void MethodAnotherContext()
using (EFContext context2 = new EFContext())
{
......................
context2.SaveChanges();
}
}
【问题讨论】:
标签: .net entity-framework transactions transactionscope