c# mapper.map code example

Example 1: c# map

var accounts = new Dictionary();

// Initialise to zero...

accounts["Fred"] = 0;
accounts["George"] = 0;
accounts["Fred"] = 0;

// Add cash.
accounts["Fred"] += 4.56;
accounts["George"] += 1.00;
accounts["Fred"] += 1.00;

Console.WriteLine("Fred owes me ${0}", accounts["Fred"]);

Example 2: c# mapper.map

var config = new MapperConfiguration(cfg => {                cfg.CreateMap();            });IMapper iMapper = config.CreateMapper();var source = new AuthorModel();source.Id = 1;source.FirstName = "Joydip";source.LastName = "Kanjilal";source.Address = "India";var destination = iMapper.Map(source);Console.WriteLine("Author Name: "+ destination.FirstName + " " + destination.LastName);

Tags:

Misc Example