entity framework 4 - Should the Unit of Work point to the service layer or the repository? -


just wondering, in asp.net mvc3 environnement entity framework. should unit of work point service layer or repository (and repository point service layer) ?

ive saw 2 example:

  • one unit of work , repository both have instance service layer..

link: entity framework 4 ctp 4 / ctp 5 generic repository pattern , unit testable

doesn't use service layer obvious 1 use in case.

  • second unit of work have instance repository have instance service layer..

link: http://blogs.msdn.com/b/adonet/archive/2009/06/16/using-repository-and-unit- of-work-patterns-with-entity-framework-4-0.aspx

what better ?

thanks.

i'm not sure mean "point to", think transactions responsibility of service layer, not persistence.

a persistence object can't know if it's part of larger unit of work. responsible service has references model , persistence objects make unit of work. service responsible managing connections pool on behalf of persistence objects well. obtain connection, open transaction, perform work, either commit or rollback transaction, , close connection. that's service's job.


Comments

Popular posts from this blog

java - SNMP4J General Variable Binding Error -

windows - Python Service Installation - "Could not find PythonClass entry" -

Determine if a XmlNode is empty or null in C#? -