Tuesday, December 25, 2018

Pattern No. 4 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,

Custom Defined Domain Oriented Data Access built on the top of EF Repository
classCustomer{DBContext.Customer+DomainOrientedMethodsforCustomer}
Domain Oriented Data Access Wrapper Class on the DBContext.Customer
“One Table Repository” based specialized Data Access Class defined by User
1. Entity-Specific Custom-Domain-Oriented Repository & UOW: Specialized Entity Repository |Further Specialized Version of 2 | Return 1 or more Entity Obj of Same Type | Multiple Tables Involve in Read | CUD Methods Update One Domain Obj | One Table Update |Entity Class has Primitive Data Types | Entity Class has Full or No Logic |DB JOINS Oriented| Repository based 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 Class | Query in more than one Table | Called in Application Service | Deals with Multiple Table Rows in Join or Views | Multiple Table Read | Domain Objects having Primitive Data Types Only | User Defined Class. | Domain Oriented User defined class around the DBContext and DBSet. | DBContext is the UOW that is used in combination with it. | No Transactions | Graphs based Queries | Class Can be further divided into Commands (CUD) and Queries (Read) | 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 comments:

Post a Comment