ServiceStack IReturn

前端 未结 3 429
滥情空心
滥情空心 2020-12-16 00:46

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

ReqDTO : IReturn> { //... }

The \"IReturn\"

相关标签:
3条回答
  • 2020-12-16 01:33

    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.

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2020-12-16 01:38

    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.

    0 讨论(0)
提交回复
热议问题