This project is read-only.

Built in transaction handling in UnitOfWork
LinqPad Example


var productRepository = new Repository<Product>(this);
var product2 = await productRepository.FindAsync(7);
product2.Dump();

// Begin transaction
unitOfWork.BeginTransaction();

try{
	product2.ProductName = "Chai4";
	product2.ObjectState = ObjectState.Modified; // always set the ObjectState
	
	// <Do other transactions here>
	
	productRepository.Update(product2);
	
	var changes = await unitOfWork.SaveChangesAsync();
	changes.Dump("changes");
	
	// Commit Transaction
	unitOfWork.Commit();
}
catch{
	// Rollback transaction
	unitOfWork.Rollback();
}

product2 = await productRepository.FindAsync(7);
product2.Dump();



Last edited Sep 23, 2014 at 7:21 PM by lelong37, version 4