Skip to content

Instantly share code, notes, and snippets.

@sholfen
Last active August 29, 2015 14:02
Show Gist options
  • Save sholfen/b3c40c7c64721b94c778 to your computer and use it in GitHub Desktop.
Save sholfen/b3c40c7c64721b94c778 to your computer and use it in GitHub Desktop.
AutoMapper demo code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AutoMapper;
namespace AutoMapperConsoleAP
{
class Program
{
static void Main(string[] args)
{
Mapper.CreateMap<TestClass1, TestClass2>();
TestClass1 t1 = new TestClass1 { Field1 = "F1", Field2 = "F2", Field3 = "F3" };
TestClass2 t2 = Mapper.Map<TestClass2>(t1);
Console.WriteLine(t2.Field1);
Console.WriteLine(t2.Field2);
Console.WriteLine(t2.Field3);
}
}
public class TestClass1
{
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
}
public class TestClass2
{
public string Field1 { get; set; }
public string Field2 { get; set; }
public string Field3 { get; set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment