2017-09-08 56 views
0

我正在使用AutoMapper來檢索Order對象。對於價格,我使用對象的擴展方法來解析,我需要傳入PriceTypeMarkup進行計算。
目前,我有它的工作只是PriceTypeAutoMapper:將2個元素傳遞給解析上下文

//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"); 

我需要在標記通過

//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"])) 

問:我如何可以設置2個元素傳遞給它的?

var s = Mapper.Map<Order, NewOrder>(order, opts => opts.Items["Pricing"] = "A"**********missing code**************); 

回答

1
opts => 
{ 
    opts.Items["Pricing"] = "A"; 
    opts.Items["Markup"] = 12; 
}