Unit of work, rollback options

I am trying to create a system that follows the repository and work pattern module to ensure constant ignorance / unit testing, etc. etc. I am looking for advice on working with rollback. Ideally, I want to use POCO, but I think I might need to at least implement an interface to provide several bits and parts.

So let's say we have two repositories, one context / unit of work.

I add one element, change another element and delete the third element. Repeat for the second repository, then I call rollback.

In the past, I used something similar to a DataSet for this. Each object has the state pendingNew, pendingAmended, pendingDeleted, clean. There is also a copy of the last saved version of the object for rollback.

How do you implement this?

EDIT:

Well, that’s what I think I'm actually trying to plunge into. Get ready for the drawings :)

The ultimate WPF MVVM project. So we look at the model that the store has ever had.

I think I tried to combine the model with the idea of ​​a repository, where, as I think, the model should use UOW and Repositories to provide the functions that the model should provide. Does this sound better?

I want complete ignorance of ignorance, so imagine that my domain includes Customer, Order and OrderLines.

In the graphical interface, you can specify one button of a new order, which allows the user to fill in customer details, order data and 1st OrderLine information. He clicks save, and they go to the database, he clicks on the cancel, which is not there.

, CustomerRepository , OrderRepository , OrderLineRepository , , .

? , , , . API . , .

EDIT 2: , .

+5
3

, , , MSDN. IUnitOfWork , .

( IUnitOfWork ) BeginTransaction(), TransactionScope(), EndTransaction(bool commit). ( ), ( ).

, .

Edit: , , UnitOfWork , . , , , .

- , , . - , , , .

(, , , ), . , , , , , .

, , , API . 1 ( ) 1 , . (imho) .

+6

- , IDbConnection . , # .

, , , . , , , , , , "commit". , , , , , , . , ; , , .

+2

, ​​, NHibernate Entity Framework.:) NHibernate POCO, .

0

All Articles