Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Repository + UnitOfWork pattern for entity framework

I was searching the net up and down and I didn't manage to find a suitable design for my application.
I am looking for Repository+UnitOfWork pattern that will manage connections and dispose them automatically when done.

I need to support both web application where each request will have its own UnitOfWork and windows application where each thread will have its own UnitOfWork. I need the patters to dispose automatically the UnitOfWork whrn request/thread is done. I also would like to support rolback in case of exception.

Right now I use StructureMap so I don't care to continue use it in the suggest answers.

The reason I need Repository pattern is to achieve all the abilities I need to all my entities. The reason I need UnitOfWork is to allow changes in more then one entity.

I will really appriciate any help.

Thanks.

like image 324
Naor Avatar asked May 17 '11 19:05

Naor


1 Answers

I used this blog as a really good starting point:

http://www.primaryobjects.com/CMS/Article122.aspx

It starts at the VERY beginning, and provides source code at the end for you. It also uses StructureMap, so it might be somewhat familiar to you.

like image 66
DanTheMan Avatar answered Nov 13 '22 00:11

DanTheMan