title: How to map objects (DTO) on client side?
body: <ul>
  <li>Typescript</li>
  <li>ABP + .NET Core</li>
  </ul>
  
  <p>I'm using a grid to insert rows (the grid I'm using is a component of the DevExtreme framework). Anyway, similar to other grids, it raises <code>onRowInserting</code> events when the records are inserted, providing the inserted row as a parameter. I need to convert that "anonymous" object (the inserted data) to my client-side DTO in this event.</p>
  
  <pre><code>onRowInserting(e) {
      let mynewrow: ItemDto = e.data; // e.data contains the inserted row
  }
  </code></pre>
  
  <p>To better understand what I need to achieve, please read this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/48792532/add-rows-to-devextreme-grid-angular-model-schema">Add rows to DevExtreme grid (angular) - model/schema</a></p>
  
  <h1>EDIT</h1>
  
  <p>The <code>ItemDto</code>:</p>
  
  <pre><code>export class ItemDto implements IItemDto {
      description: string;
      note: string;
      quantita: number;
      postId: number;
      id: number;
  
      constructor(data?: IItemDto) {
          if (data) {
              for (var property in data) {
                  if (data.hasOwnProperty(property))
                      (&lt;any&gt;this)[property] = (&lt;any&gt;data)[property];
              }
          }
      }
  
      init(data?: any) {
          if (data) {
              this.description = data["description"];
              this.note = data["note"];
              this.quantita = data["quantita"];
              this.postId = data["postId"];
              this.id = data["id"];
          }
      }
  
      static fromJS(data: any): ItemDto {
          let result = new ItemDto();
          result.init(data);
          return result;
      }
  
      toJSON(data?: any) {
          data = typeof data === 'object' ? data : {};
          data["description"] = this.description;
          data["note"] = this.note;
          data["quantita"] = this.quantita;
          data["postId"] = this.postId;
          data["id"] = this.id;
          return data; 
      }
  
      clone() {
          const json = this.toJSON();
          let result = new ItemDto();
          result.init(json);
          return result;
      }
  }
  
  export interface IItemDto {
      description: string;
      note: string;
      quantita: number;
      postId: number;
      id: number;
  }
  </code></pre>
  
  <p>And below, the content of <code>e.data</code> (at this moment, I've added only some columns to the grid, so not all fields are present).</p>
  
  <pre><code>Object {
      __KEY__: "7c2ab8-1ff6-6b53-b9d7-ba25c27"
      description: "mydescription"
      id: 32
      note: "mynote"
      postId: 4
      quantita: 2
       &gt;  __proto__: Object { constructor; , _defineG....
  }
  </code></pre>
  
  <p>This image represents the object better: <a href="https://imgur.com/ihVZrDh" rel="nofollow noreferrer">https://imgur.com/ihVZrDh</a></p>
  
  <p>I'm not sure what I did in the line <code>let mynewrow: ItemDto</code>.
  I don't know if it is correct, or if it is enough to use the variable later, passing it to the service that saves the new row.</p>