I have this code:
Mapper.AddMap<Product, DetailsVM>(src =>
{
var res = new DetailsVM();
res.InjectFrom(src); // maps properties with same name and type
res.test = "asd";
return res;
});
productVM.InjectFrom(test);
I have everything working and this is my VM:
public int ProductId { get; set; }
public decimal Cost { get; set; }
public decimal UnitPrice { get; set; }
public int OnHandQty { get; set; }
public ProductPicture thumb { get; set; }
public ProductPicture main { get; set; }
public string test { get; set; }
the actual model doesn't have the property test
, I simply want to set test
to any string. how do I do it? I keep on getting null
whenever i try to map.
you need to call Mapper.Map
instead of InjectFrom
,
InjectFrom
is not affected by Mapper.AddMap