I have created a new service with the ServiceStack Visual Studio add-in ("ServiceStack ASP.NET Empty") template.
This creates 4 projects, ServiceModel, ServiceInterface, ServiceHost, and a test project. If I were to encapsulate my data access with the REPOSITORY pattern via an Interface (think dependency injection), and was not allowed to add any other projects to the solution, what project should contain this code, and why? If the repo code absolutely had to be moved out to another project what would the projects dependencies be i.e. ServiceModel, ServiceInterface ?
Thank you, Stephen
ServiceHost, and a test project. If I were to encapsulate my data access with the REPOSITORY pattern via an Interface
See the Physical project structure wiki for more information on physical project layout.
ServiceStackVS's VS.NET templates follows the above physical project structure where only the ServiceInterface
is used for maintaining your Services implementation and custom logic. All other starting projects have different purposes, e.g.
Host
project is the glue where all your concrete dependencies are registered and wired together that otherwise should be kept light-weight and logic-free. ServiceModel
project is a dep/impl-free project for maintaining your Services Contract DTOs which should be kept free of Server implementations so it's re-useable in client projects.Both the interfaces and implementation can go in the same project. Some ServiceStack demos following this layout is the IRepository class in RedisStackOverflow as well as the IEmailer class in EmailContacts.