c# - Do I neet Unity of Work and Repository patterns when working with Entity Framework? -
so @ job pointed http://www.codeproject.com/articles/990492/restful-day-sharp-enterprise-level-application#_toc418969121 , told learn these patterns , implement them in solution.
what confused me these things before entity framework 6 , understood, unity of work used optimize database performance grouping queries together. since ef6 has these optimizations, should still implement these layers? layerness helps modularization , switching of data source. mean ef6 complex implement these patterns , should ado.net used directly or that?
edit: i've noticed added layer allows usage of mock data sources. not sure how useful because of need add layer of apstraction
"unit of work used optimize database performance grouping queries together." - not correct. unit of work there collect related operations single transaction committed or rolled whole. tracks changes made objects required database operations can deduced automatically , performed on behalf.
when work entity framework, use create dbcontext model. class both repository , unit of work, don't have special. things become more complicated when project becomes large dbcontext becomes more of burden.
Comments
Post a Comment