I like to use the new api i ServiceStack, and have a few Pocos in a legacy project which I like to keep unchanged. However it feels a bit unnessasary to duplicate them to Dto's in my ServiceStack project. Can I be lazy and "pass through" properties to my legacy pocos somehow?
This works nice with a JsonServiceClient, but adds an extra level to the json, which I don't like:
[Route("/legacytype", "POST,OPTIONS")]
public class RequestLegacyTypePost : IReturn<int>
{
public LegacyTypeLegacyType{ get; set; }
}
public class LegacyTypeService : Service
{
public object Post(RequestLegacyTypePost request)
{
return db.Insert(request.LegacyType);
}
}
Copy-n-paste properties to a DTO way naturally works fine:
[Route("/legacytype", "POST,OPTIONS")]
public class RequestLegacyTypePost : IReturn<int>
{
public int Id { get; set; }
public string SomeProp { get; set; }
public string OtherProp { get; set; }
}
And perhaps that simplt is best practice?