Skip to content

Instantly share code, notes, and snippets.

@bondsbw
Last active September 21, 2016 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bondsbw/5e5b70873a7b67fe281efceade2a7e25 to your computer and use it in GitHub Desktop.
Save bondsbw/5e5b70873a7b67fe281efceade2a7e25 to your computer and use it in GitHub Desktop.
Automapper missing map exception
void Main()
{
var profile = new MyProfile();
Mapper.Initialize(cfg => cfg.AddProfile(profile));
}
public class MyProfile : Profile
{
protected override void Configure()
{
CreateMap<Base, string>()
.Include<Derived, string>()
.ConvertUsing(src => src == null ? null : src.Value);
}
}
public class Base
{
public string Value { get; set; }
}
public class Derived : Base
{
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment