jeudi 9 juin 2016

Work with database transactions in a functional manner in C#

I was looking at this kind of code and wondering, is there anything that can be improved if you approach from functional programming perspective?

You don't have to strictly re-implement my example to answer, if you have different example involving Transactions, that would be great.

using (var unitOfWork = _uowManager.Begin())
{
    _paymentRepository
       .InsertOrUpdate(payment); // Returns payment instance

    // Being executed to get Payment.Id
    _uowManager
       .SaveChanges();

    _otherRepository
       .OtherMethod(payment.Id); // Could be changed as necessary

    unitOfWork
       .Complete()
}

Code above is based on ASP.NET Boilerplate and Entity Framework if it helps.

Aucun commentaire:

Enregistrer un commentaire