Using OpenAccess ORM and ServiceStack

Service-Oriented Architecture

Service-Oriented Architecture is a set of services, where each service is a standalone loosely coupled unit. Each service receives one or more requests and provides responses to these requests using defined interface. SOA allows effective and flexible communication between systems regardless of technology they are built with.


ServiceStack is an open-source .NET and Mono REST Web Services framework, which provides simple, cleaner POCO-driven way of creating web services. Additional information why you should choose ServiceStack can be found here.

OpenAccess ORM and ServiceStack

It is very easy to integrate OpenAccess ORM as a persistence solution and use it from a ServiceStack web service.
Let’s start with the setup of ServiceStack, you could use the NuGet package manager to do that:

Install-Package ServiceStack

Before moving to the implementation of the service we will register it together with its dependencies. The following code snippet should be added under the Global.asax.cs file:

There are three parts in a ServiceStack service: Request DTO, Response DTO and the service implementation. In this blog post we will read category data filtered based on its identity. This means we need an appropriate request DTO:

The service will return the following response:

Note the name of the response DTO. It is constructed by appending Response to the request DTO name. This is the convention used by ServiceStack. To support automatic exception handling a ResponseStatus property is added to the response DTO class.

And here is the implementation of the service itself:

If everything is configured correctly, you could run the service and go to http://[server_uri]/get-category/1 to see your OpenAccess ORM ServiceStack web service in action.

The complete demo application can be found here.