Take the 2-minute tour ×

i have used the repo pattern in my web forms application in the following way

UI Layer:

it contains the code behind files in which the controls are being binded and user actions like insert update etc are catered for

the UI Layer calls the

Repository Layer:

it contains the repository classes inheriting the GenericRepo:IGeneric

and the

Data Layer:

it contains the EF generated domain classes

the layers are strict for the time being that is the UI layer calls the Repo layer and it in turns call the data layer to fetch the data.


now the problem im facing is that if for example i need a list of products on the Products.aspx page i need to do some thing like

IProductRepo pr = new ProductRepo();

IList<Products> lstProducts = pr.GetAll();

i dont want to add the reference of Data Layer to the UI layer in order to access the domain entities i.e generated by the EF

what are my options? please guide me to the right path


share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

In my opinion you're missing a layer. I would built it like this:

UI                |
-----             |
**Domain**        |   Domain classes
-----             |
DAL (Repository)  |

This way your logic is in a separate layer and your DAL is completely hidden from your logic and domain model.

Another way you could solve this problem is by using Dependency Injection. That way you can define some interfaces and only keep references to interfaces. With a dependency container you can ten tie those references to real types.

My preferred DI container is for example Ninject

share|improve this answer
tnx for your time, can you explain the diff b/w Domain and Domain Classes what should i have in the Domain Layer? –  dakait May 10 '13 at 22:05
The domain layer would be your services, the classes that coordinate the transactions between UI, Domain Classes and DAL. –  Kenneth May 10 '13 at 22:20
add comment

Your Answer


