SqlServer CE 4.0に対して、およびTransactionScope内でこれを使用すると、例外をスローするコードがいくつかあります。最初にコード、次にエラー。
// Arrange.
// ... some stuff ...
// like .. order = get order with ID #1.
// Act.
using (new TransactionScope())
{
order.Name = name; // Update a field.
_orderRepository.Save(order);
_unitOfWork.Commit(); // <-- this works 100% fine.
// Assert.
// Reload the order so we can see if the data persisted to the DB.
var updatedOrder = _orderRepository
.Find()
.Where(x => x.OrderId == 1)
.SingleOrDefault(); <-- // this throws the exception.
Assert.IsNotNull(updatedOrder);
Assert.AreEqual(name, order.Name);
}
例外エラーは次のとおりです。-
System.Data.EntityException:基になるプロバイダーがOpenで失敗しました。---> System.InvalidOperationException:接続オブジェクトをトランザクションスコープに参加させることはできません。
したがって、最初の保存/コミットは正常に機能しますが、オブジェクトを再度取得しようとすると(データがトランザクションに保持されているかどうかを確認するため)、エラーが発生します。
これは分散トランザクションではなく単一トランザクションであると確信しています...だから、これはうまくいくはずだと思いますか?
提案、親切な人?