Skip to content

Instantly share code, notes, and snippets.

@Layoric
Last active September 1, 2016 02:31
Show Gist options
  • Save Layoric/12ff6d11d909412f8f29006386b8789e to your computer and use it in GitHub Desktop.
Save Layoric/12ff6d11d909412f8f29006386b8789e to your computer and use it in GitHub Desktop.
Auto mapping
using System;
using ServiceStack;
using ServiceStack.Text;
public class GetPersonResponse
{
public string FirstName { get;set; }
public string LastName { get;set; }
public int Age { get;set; }
}
public class Person
{
public string FirstName { get;set; }
public string LastName { get;set; }
public int Age { get;set; }
}
var person = new Person {
FirstName = "Bob",
LastName = "Smith",
Age = 40
};
var personResponse = person.ConvertTo<GetPersonResponse>();
Console.WriteLine(personResponse.GetType().Name);
personResponse.PrintDump();
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="4.0.62" targetFramework="net45" />
<package id="ServiceStack.Client" version="4.0.62" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="4.0.62" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment