Reputation: 49
Recently I learned Unit of work in entity framework.Now one question cames in mind is that what is the difference between TransactionScope and unitOfWork layer.I think both are doing same thing.Is it correct?
Upvotes: 4
Views: 3089
Reputation: 1561
Transactions are an implementation of the design pattern Unit of Work
.
What we are talking about here is just the level of abstraction.
Unit of work
which is applicable to anything.Transactions
.Entity Framework
which is a dot net repository level abstraction which implements Transactions
.SQL Server
which is wrapped and used by Entity Framework
So basically, it is the context. If we are talking in terms of a RDMS we would say Transaction
. In a dot net context, you can say Transaction Scope
and in a software design context, it is a Unit of Work
.
Upvotes: 0
Reputation: 1514
They are two completely different things. Unit of work is a design pattern or a set of guidelines for how to solve a software problem. TransactionScope is a class that I can use to programmatically define just that, a scope for a transaction.
More info here:
TransactionScope - https://msdn.microsoft.com/library/bb738523(v=vs.100).aspx
Upvotes: 3