public class Source
{
public int Id { get; set; }
public string Name { get; set; }
}
public class Destination
{
public Dictionary Items { get; set; }
}
var sourceList = new List
{
new Source { Id = 1, Name = "Item 1" },
new Source { Id = 2, Name = "Item 2" }
};
var configuration = new MapperConfiguration(cfg =>
{
cfg.CreateMap, Dictionary>()
.ConstructUsing(src => src.ToDictionary(s => s.Id, s => s.Name));
});
var mapper = configuration.CreateMapper();
var destination = mapper.Map(sourceList);
// Result
// destination.Items[1] = "Item 1"
// destination.Items[2] = "Item 2"