Created
October 31, 2013 12:10
-
-
Save idursun/7248645 to your computer and use it in GitHub Desktop.
Automapper nullable property mapping
This file contains 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 AutoMapper; | |
namespace ConsoleApplication14 | |
{ | |
class Program | |
{ | |
class Source | |
{ | |
public int? A { get; set; } | |
} | |
class Target | |
{ | |
public int? A { get; set; } | |
} | |
static void Main(string[] args) | |
{ | |
Mapper.CreateMap<Source, Target>(); | |
Source source = new Source() { A = 5 }; | |
Target target = new Target() { A = 5 }; | |
Mapper.Map<Source, Target>(source, target); | |
Console.WriteLine(source.A); | |
Console.WriteLine(target.A); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment