Skip to content

Instantly share code, notes, and snippets.

@idursun
Created October 31, 2013 12:10
Show Gist options
  • Save idursun/7248645 to your computer and use it in GitHub Desktop.
Save idursun/7248645 to your computer and use it in GitHub Desktop.
Automapper nullable property mapping
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