Two types of Entity Repository Classes
Two types of Entity Repository Classes
EF provided Entity Repository Classes get by
DBContext.Repositories
Custom defined Entity Repository Classes that encapsulate
the DBContext inside it and provide limited controlled access for Persistence
Logic against an Entity
How DBContext, DBSet, Repositories, UOW, Entity-EF
Repository, Entity-Specific-CRUD Repository, Entity-Specific-CRUD-Generic
Repository and Complex-Domain Repository are all related to each other
DBContext
== Database of SQL Server DB
DBSet == Table in SQL Server DB
DBContext
== Entity Repository based UOW
DBSet == Entity based Repository
DBContext is a UOW, when we create an
instance of DBContext we start a UOW for set of DBSets collections defined
inside that UOW
DBSet is a repository that is contained
inside the DBContext.
Both Repository and UOW Patterns work side by
side. They do not work isolation.
EF is totally based on Repository and UOW no
matter whatever type of Data Access Code we are writing.
EF is an abstraction on the top of ADO.NET that
save us from the dirty and repeative work while reading and writing to DBMS.
Web Apps need disconnected connection with
EF, therefore we dispose the DBContext object as early as possible after using
it.
Desktop Apps need connected connection with
EF, therefore we dispose the DBContext object after doing series of operations.
No comments:
Post a Comment