BLL'de TransactionScope
kullanıyorum. Veri erişim katmanında, her hamla için kendi Context
'u oluşturan depo sınıflarım var. Bu işe yarayacak mı? BLL'dekiTransactionScope farklı Bağlam nesnesinde çalışıyor mu?
: DataAccess yılında
using (var scope = new TransactionScope(TransactionScopeOption.Required))
{
rep.addItme(Myentity);
rep.updateItme(MyAnotherEntity);
scope.Complete();
}
:
class rep
{
void addItmem(Entity entity)
{
using(var context=new MydbContext)
{
//---state is set here
context.Entity.add(entity);
context.SaveChanges();
}
}
void updateItem(Entity entity)
{
using(var context=new MydbContext)
{
//--state is set here
context.Entity.add(entity);
context.SaveChanges();
}
}
Evet. En iyi yol test etmektir. UpdateItem'de bir istisna atmaya çalışın ve bakın. –