I am using AutoMapper to retreive an Order object. For the price, I resolve using an extension method of the object and I need to pass in a PriceType and a Markup for the calculation.
Currently, I have it working for just PriceType
//in the mapping
.ForMember(d => d.TotalPrice, opt => opt.ResolveUsing((src, dest, destMember, resContext) => dest.TotalPrice= src.UserTotalPrice((string)resContext.Items["Pricing"])))
//pass in the variable
var s = Mapper.Map<Order, NewOrder>(order, opts => opts.Items["Pricing"] = "A");
I need to pass in the markup
//in the mapping
.ForMember(d => d.TotalPrice, opt => opt.ResolveUsing((src, dest, destMember, resContext) => dest.TotalPrice= src.UserTotalPrice((string)resContext.Items["Pricing"]),(decimal)resContext.Items["Markup"]))
Question: How can I set 2 elements with passing it in?
var s = Mapper.Map<Order, NewOrder>(order, opts => opts.Items["Pricing"] = "A"**********missing code**************);
opts =>
{
opts.Items["Pricing"] = "A";
opts.Items["Markup"] = 12;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With