Last active
August 29, 2015 14:02
-
-
Save sholfen/b3c40c7c64721b94c778 to your computer and use it in GitHub Desktop.
AutoMapper demo code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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