TransactionScope内でSqlServer CE 4.0 &に対してこれを使用すると、例外をスローするコードがあります。まず、コード、次にエラー。EFで単純なトランザクションを試すCTP5とSqlServerCE4.0 ==が失敗しました。どうして?
// 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:接続オブジェクトは トランザクションスコープに参加できません。
最初の保存/コミットはうまく動作しますが、エラーが発生したときにオブジェクトを再度取得しようとしたとき(データがトランザクション内に残っているかどうかを確認するとき)に動作します。
は今、私は、これは単一トランザクションない分散トランザクションであると確信している...ので、私はこれがちょうど動作するはずと仮定していますか?
提案、種類フォーク?
SQLCEはのTransactionScopeをサポートしていません。通常のDBトランザクションを使用します。 – leppie
これは数週間前にこれが尋ねられましたが、私は今質問を見つけることができません。 – leppie
可能な重複:http://stackoverflow.com/questions/1554473/linq-to-sql-does-sql-server-compact-ce-support-a-requiresnew-transaction-scop – leppie