Stefan Tsalapatis - 501 - Jan 16, 2014

Hi,
A question:  Can we use nested classes for DTO’s  ? (json & protobuf)?  any side effect  or  architectural problem?
e.g   public class CustomerDirectoryResponse
         {   
                 public  class  Contact
                { 
                        string  name {get; set;}
                        string  address {get; set;}
                 }
              public List<CustomerDirectoryResponse.Contact>
                                       CustomerDirectory_list  {get; set;}
                   }
It will help me a lot, if possible. I have a lot of queries with DTOs auto generated from our utility.
thanks

 

Have you tried? Was there an issue?

Stefan Tsalapatis:

+Demis Bellot   I don’t think that there is issue…  I ask  before  heavy  refactoring , if there is an experience on that.
I create DTOs for every query,  many times they are for one use only  as result sets. Till now  they are  independent. If I tie them to response, it will be much easier.  All DTOs , responses, and requests are auto-generated.

Just try things out with a small examples first. Post on ServiceStack/Issues or here if you end up running into any issues or it doesn’t behave as expected.

Stefan Tsalapatis:

+Demis Bellot   Tested. Nested classes in Responses work excellent  for  both JsonServiceClient and ProtoBufServiceClient.
Applying only the indexers for protobuf in Responses-Requests.
This is a great advantage for queries, multiple result sets and DTO naming.