Tuesday, December 25, 2018

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

We selected the Data Access Pattern, by seeing how FAT the Domain Scenario/Feature is. Request Processing Pipeline for different scenarios.

This pattern about the Default Table Gateway Provided by EF
<== DBContext.Customer (All EF CRUD Methods or DBSet Operations)
“One Table Repository” based Data Access Class provided by EF’s DBContext

1. Entity-Specific EF-CRUD Repository & UOW: EF Repository |DBContext based Repository | Return 1 or more Domain Obj of same type | CUD Methods Update One or MORE Domain Obj(s) | Underlying Domain Class has Primitive Data Types | Domain Class can has Full or No Domain Logic | CRUD Oriented Methods| Repository Data Class | |Query or Save in 1Table | DBContext is UOW | Naked Repository | It provides extensive CRUD logic against Domain Object provided by EF this is negative as clients may use them in any way | Called in Application Service by Generic Interface | Deals with One Table Row CUD Operations | Read may return IEnumerables of Domain Objects | Domain Objects having Primitive Data Types Only, User Defined Class. By default what we get from the EF is the Entity-EF Repository. We get it by DBContext.repository . DBContext is the UOW that is used in combination with it. | DBContext Class is directly accessed inside the App. Service not recommended| Interface can be defined for DBContext Class as done in Mattew Renzee Course no recommended |

No comments:

Post a Comment