The data access layer is the layer between the business layer and a database or external services. The data access logic is responsible for persisting business entities to a database and retrieving individual business entities or sets of business entities on behalf of the business layer.
Handling Transaction in Business Logic Layer
using(TransactionScope scope = new TransactionScope())
{
OrderProvider.UpdateOrder(order);
ProductProvider.UpdateProduct(product);
scope.Complete();
}
Transaction should be implemented in Business Logic Layer(BLL), instead of Data Access Layer(DAL), because BLL is "business oriented", in other words, transaction is a business constraint. On the other hand, DAL is "data oriented", it has no idea what operations should be in a transaction.
concerns:
RDBMS support nested transaction, stored procedures are implicitely or explicitely under transactions, also in BLL or even DLL may have nested transaction, make them work together may be a challenge.
using (using(TransactionScope scope1 = new TransactionScope()))
{
using (using(TransactionScope scope2 = new TransactionScope()))
{
...
scope1.Complete();
}
scope2.Complete();
}
No comments:
Post a Comment