Pergunta

I have a web application that is developed using ASP.NET MVC.

The application follows the nth-tier architecture, and I have divided the application into 4 different project which are Model, Core, Framework and the web application.

The Model, Core and Framework are DLLs, the Model contains just my POCO classes, the Core contains my DbContext, repositories and Unit of Work implementations while my framework project contains classes that would be used directly by my MVC web application such as action-link extension, custom view engines e.t.c.

In addition to my framework I created a class called service which makes method calls to the repositories in my core DLL and method in the service class are called by my web application.

My question is: Is it ideal to channel method calls from the web application to the repository through my the service class in my framework DLL or just make a direct call to the Core DLLs?

Foi útil?

Solução

Don't add an abstraction layer unless you require it. If you don't have a strong reason to add a service layer in the middle, you will end up implementing the Poltergeist anti-pattern, where sole purpose is to pass information to another object.

In general, calling your repository directly is perfectly fine so you have to analyze if you foresee any particular restriction disallowing this schema.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top