简体   繁体   中英

Understanding the unit of work pattern

in my new c# project i want to implement the unit of work pattern.

According to Fowler a unit if work keeps track of all changes to your corresponding objects (newly created, dirty and removed objects). Other implementations like this one jgauffin - ado.net the right way use the unit of work "just" for transaction management. So a unit of work after Fowler is initialized at the start of the application and is kept in memory. The "other" unit of work is only used for transactions and is disposed afterwards.

Why are these approaches so different? Is there a go-to-implementation?

Thx in advance

a unit of work after Fowler is initialized at the start of the application and is kept in memory

No, it's not:

[Folwer] A Unit of Work keeps track of everything you do during a business transaction that can affect the database.

Something like "create the invoice and invoice lines for this order" is done using one unit of work instance. This UoW is disposed after committing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM