title: REST API (ASP.NET Web API 2) best practices: How to return 1 - N items that are not one type but 3 related types?
body: <p>I have 3 types like below. Different models can have different attributes. An attribute is a code description attribute meaning that it's limited set of values.</p>
  
  <pre><code>CarModel
  {
     int Id;
     string Name;
  }
  
  CarAttributeType
  {
       int Id;
       int ModelId;
       string GroupName;
       int DataOrder;
       bool Mandatory;
       // default values etc.
  }
  
  CarCodeDescriptions
  {
      int Id;
      int AttributeTypeId;
      int Code;
      int Descr;
  }
  </code></pre>
  
  <p>To use this model for actual cars there is explanation in the end.</p>
  
  <p>Ok. Now I want to have GET, POST and PUT operations that client can fetch, add and update whole model. Do I make a type that contains all these </p>
  
  <pre><code>CarModelContainer
  {
      CarModel Model;
      IEnumerable&lt;CarAttributeType&gt; Attributes;
      IEnumerable&lt;CarCodeDescriptions&gt; Attributes;
  }
  </code></pre>
  
  <p>and then have:</p>
  
  <pre><code>[Route("carmodels/{id:int}"")]
  public CarModelContainer Get(int id)
  {
      return Persistence.Instance.GetCarModel(id);
  }
  
  [Route("carmodels")]
  public IEnumerable&lt;CarModelContainer&gt; GetAll()
  {
      return Persistence.Instance.GetCarModels();
  }
  </code></pre>
  
  <p>or is it desireable to do this somehow (out parameters or something) without making this container class? I'm truly lost here.</p>
  
  <p>To use model for actual cars:</p>
  
  <pre><code>Car
  {
      int Id;
      int ModelId;
      //ETC
  }
  
  CarAttribute
  {
      int Id;
      int CarId;
      int CatAttributeTypeId
      int CodeValue;
  }
  </code></pre>