Below is the source code for a service. Prove that:
- The service has a transaction when it is called.
- The transaction is disposed.
- The code is thread safe.
public Order GetOrder(int orderId)
{
return InvokeGetOrder(() => OrderServiceProvider.GetOrderWithItems(orderId));
}
public Order InvokeGetOrder(Func<Order> function)
{
Order order;
using (IBusinessTransactionContext currentBusinessTransactionContext =
new AcidBusinessTransactionContext(_container, false))
{
OrderServiceProvider.BusinessTransactionContext =
currentBusinessTransactionContext;
order = function();
OrderServiceProvider.BusinessTransactionContext.Commit();
}
return order;
}