Tuesday, December 25, 2018

Pattern No. 3 for Encapsulating EF based Data Access Code

We are using Data Mapper + Domain Model + Service Layer + Repository + UOW from MF Patterns of EAA in the modern OCH based Applications and Frameworks. 

Julie Lermen has identified 5 Pattern to encapsulate the Data Access Code. All these Patterns are based on Repository and UOW.

All these five Pattern are Repository  and UOW Based Solutions,


Generic Defined Table GateWay built on the top of EF Repository
 class IEntity<*> { DBContext.* + Generic CRUD Methods for Entity }
Data Access Wrapper Class on the DBContext.*
“Generic One Table Repository” based Data Access Class defined by User
1. Entity-Specific Custom-CRUD-Generic Repository & UOW: Generic Entity Repository |Generic Version of 2 | Rest is Same as 2 | Return 1 or more Domain Obj of same type | One Table involve in Read or Update | CUD Methods Update One Domain Obj |One Table Update | Underlying Domain  Class has Primitive Data Types | Domain Class can has Full or No Logic |No DB Joins |CRUD Oriented Methods| Repository Data Class | DBContext is Wrapped Inside class | DBContext is UOW | Encapsulated Repository | It provides limited CRUD logic against Domain Object provided by EF it is positive as we control the how clients use the Data Access Code| Custom Repository based Data Access Class | Query or Save in 1Table | Called in Application Service by Generic Interface | Deals with One Table Row CUD Operations | Read may return IEnumerables of Domain Objects | Domain Objs having Primitive Data Types Only | User Defined Class. | User defined class around the DBContext and DBSet. |DBContext is the UOW that is used in combination with it. | In order to use this Class as pluing in Application Service, define Interface in App. Service Layer and this class implements this interface. | This class is defined in the Data Project | No Transactions

No comments:

Post a Comment