11

I am looking at the new api that came out 2 weeks ago. It seems like

ReqDTO : IReturn<List<ResDTO>> { //... }

The "IReturn" bit seems to be optional? The DTOs in RazorRockstars demo project works without it.

Tom
  • 15,781
  • 14
  • 69
  • 111

3 Answers3

19

This is a new addition in ServiceStack's New API which allows you to document the expected Response Type that the Request DTO will return, e.g. with

ReqDTO : IReturn<List<ResDTO>> { ... }

Which lets you call using any of the C# Service Clients with:

List<ResDTO> response = client.Get(new ReqDto());

If you didn't have the IReturn marker your client call would have to look like:

List<ResDTO> response = client.Get<List<ResDTO>>(new ReqDto());

Which is something the client/consumer of your service needs to know about. If you had the marker on the DTO the response type is already known.

The IReturn<> marker is also used to determine the Response DTO that's used in the HTTP Responses in ServiceStack's /metadata pages.

mythz
  • 141,670
  • 29
  • 246
  • 390
  • 1
    Using ServiceStack 3.9.x and I'm just wondering if the `IReturn` is enforced at all? i.e. if my endpoint returns data that does not match the type specified, should it throw exceptions? – JaKXz Apr 15 '15 at 16:10
1

As far as I know, this is just a convenient way of defining your request/response DTOs. You're free to use it, or not.

Alexis
  • 387
  • 4
  • 12
1

In the case where you define your DTOs in a portable class library, you won't be able to use IReturn. Perhaps IReturn should be defined in a PCL in ServiceStack. Just a thought.

Guy Godin
  • 448
  • 5
  • 16