title: Sending a List of heterogeneous objects
body: <p>I have a series of "Messages" to be sent to a server application from a mobile client.
  Each message has some common information (MAC, timestamp etc) and its 
  So <code>ObjMessage</code> is the base class that has a <code>MessageInfo</code> and a <code>TransactionInfo</code> class, then I have a <code>ObjReqMsg1</code> and <code>ObjReqMsg2</code> that differ for a int and string property, just for test.</p>
  
  <p>// Messaging classes</p>
  
  
  
  <pre class="lang-cs prettyprint-override"><code>[ProtoContract]
  public class MessageInfo
  {
      [ProtoMember(1)]
      public string MAC { get; set; }
      [ProtoMember(2)]
      public string version { get; set; }
      [ProtoMember(3)]
      public Guid guidMessage { get; set; }
      [ProtoMember(4)]
      public DateTime timeGenerated { get; set; }
  }
  
  [ProtoContract]
  public class TransactionInfo
  {
      [ProtoMember(1)]
      public string user1 { get; set; }
      [ProtoMember(2)]
      public string user2 { get; set; }
      [ProtoMember(3)]
      public DateTime timeOperation { get; set; }
  }
  
  
  [ProtoContract]
  public class ObjMessage
  {
      [ProtoMember(1)]
      public TransactionInfo transactionInfo { get; set; }
      [ProtoMember(2)]
      public MessageInfo messageInfo { get; set; }
  }
  </code></pre>
  
  <p>// LIST of different messages</p>
  
  <pre class="lang-cs prettyprint-override"><code>[ProtoContract]
  public class ObjReqMsg1 : ObjMessage
  {
      [ProtoMember(1)]
      public int intValue { get; set; }
  }
  
  [ProtoContract]
  public class ObjReqMsg2 : ObjMessage
  {
      [ProtoMember(1)]
      public string stringValue { get; set; }
  }
  
  
  [ProtoContract]
  public class ReqListMessages : IReturn&lt;RespListMessages&gt;
  {
      [ProtoMember(1)]
      public List&lt;ObjMessage&gt; objsReqMessage { get; set; }
  }
  </code></pre>
  
  <p>All my tests are done with json and protocol buffers, and sending single messages of lists of eterogeneous messages works.</p>
  
  <p>My questions are:
  1) my idea, instead of sending ten <code>ObjReqMsg1</code> requests, is to make just one request with a <code>List&lt;ObjReqMsg1&gt;</code>, to save on network calls. It works and it actually saves some time, does it make sense? Or it would be more correct to make the 10 calls?</p>
  
  <p>2) Then, if it makes sense and is the right path, i thought it would be great instead of making two <code>List&lt;ObjReqMsg1&gt;</code> and <code>List&lt;ObjReqMsg2&gt;</code> calls, to make a single <code>List&lt;ObjMessage&gt;</code> call, and on the server check if each <code>ObjMessage</code> is <code>ObjReqMsg1</code> or <code>ObjReqMsg2</code> , cast and act accordingly.Is it feasible?</p>
  
  <p>If it is, what am I doing wrong, because, when I create a <code>List&lt;ObjMessage&gt;</code> adding 3 <code>ObjReqMsg1</code> and 3 <code>ObjReqMsg2</code>, and checking with inspector that <code>intValue</code> and <code>stringValue</code> are present, when I do:</p>
  
  <pre class="lang-cs prettyprint-override"><code>string serialized = ServiceStack.Text.JsonSerializer.SerializeToString&lt;ReqListMessages&gt;(reqListMessage);
  </code></pre>
  
  <p>I don't find <code>intValue</code> and <code>stringValue</code> serialized.</p>
  
  <p>And obviously on the server side I receive a list of 6 <code>ObjMessage</code>, instead of a list of 3 <code>ObjReqMsg1</code> + 3 <code>ObjReqMsg2</code>.</p>
  
  <p>Can you help?
  Thanks</p>