0

I am planning to use Entity Framework for my project but it might change, so I have decided to abstract that layer.

I want a class that implements IUOW that i can pass to my repositories so that all the db call are made in one transaction.

Now every example I see on net, has dbContext in the class implementing IUOW, ,isn't it a constraint, that I need dbContext object, what if I want to create repositories that just call stored procedures. I won't be having dbContext then.

http://www.asp.net/mvc/overview/older-versions/getting-started-with-ef-5-using-mvc-4/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Zaid Bin Irfan
  • 330
  • 1
  • 13

1 Answers1

0

I understand that you should create an interface (IPersistence... IData, somthing like that) and implements it with its dbContext as something only visible to the class which implements EntityFramework calls (EntityPersistence : IPersistence). I guess you can take a look at this example: https://codereview.stackexchange.com/questions/47879/unit-of-work-and-repository-with-entity-framework-6

What do you mean by "all the db call" are made in one transaction? As far as I know, dbContexts try to make it all on one transaction. But if you need extra encapsulation, I would consider using TransactionScope. With this, you can easily make an application cross several layers with one transaction, handling errors, etc. (Take a look at these articles: http://msdn.microsoft.com/en-us/data/dn456843.aspx)

Community
  • 1
  • 1
rodrigogq
  • 1,943
  • 1
  • 16
  • 25