Reputation: 36166
First I decided to create one Interface called it IDataAccessLayer
and started putting everything into it: methods like GetUsers()
, GetUser(int id)
, GetOrderByNumber(int number)
, DeleteOrder(int Id)
etc.
That worked just perfect at first. But then I realized that the concrete implementation of DataLayer:IDataLayer
is growing to big. I decided to cut it into several partial class files. Still I was feeling that I'm doing something really wrong.
Then I decided to create interfaces for each logical part like IUsers
, IOrders
, IItems
etc. Didn't work, because I was accessing repository through one dependent property injected into controller's constructor. So I couldn't just add another property everytime I need to use different type of dataContext in my controller.
Then after many hours reading through articles about Entity Framework, I finally realized that I have to use Repository and Unit of work patterns. And still I need to somehow separate POCOs from my ViewModel objects, although almost all the time they'd be sharing similarities. Automapper helps a lot. But now, I'm not sure how to use everything together. Entity Framework, Patterns, Automapper and Dependency injection framework like Ninject.
I don't have clear understanding how to mix that all into one awesome architecture. Can you please show me some nice examples.
Upvotes: 4
Views: 3794
Reputation: 123
You might take a look at this sample (MVCArch) I've written some months ago. It takes advantages of :
Hope this helps.
Upvotes: 3
Reputation: 5461
First here is an overall article about n-tier architecture using the Repository and UnitOfWork principles: link. I have some experience working with EF and the afore mentioned patterns and I found this article of great help.
Take a look here as well as here for the MSDN articles on those principles.
Regards.
Upvotes: 2