I would recommend you not calling services in a Razor template. A Razor template should be used only to render some markup from a model.
The actual data access should be performed in the ServiceStack service that rendered this template. So in your case you could call another service from the operation:
public object Get(SomeRequestDto message)
{
var response = this
.ResolveService<SMSGateway.Services.EntityService>()
.Get(new SMSGateway.Services.EntitiesRequest()
);
return response.Rersult;
}
or you might leave the container to inject the dependent service into the current service so that you don't even need to be using some service locator anti-patterns.
public SomeService: Service
{
private readonly EntityService entityService;
public SomeService(EntityService entityService)
{
this.entityService = entityService;
}
public object Get(SomeRequestDto message)
{
var response = this.entityService.Get(new SMSGateway.Services.EntitiesRequest()
return response.Rersult;
}
}
and then your Razor view will of course be strongly typed to the corresponding model:
@model IEnumerable<WhateverTheTypeOfTheResultYouWannaBeLoopingThrough>
foreach (var entity in Model)
{
<li>
<a href="@entity.MetaLink.Href">
@Html.TitleCase(entity.Name) entities
</a>
</li>
}