我正在使用 AutoMapper 来检索 Order 对象。对于价格,我使用对象的扩展方法解析,我需要传入 aPriceType和 aMarkup进行计算。
目前,我让它只为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");
Run Code Online (Sandbox Code Playgroud)
我需要传递标记
//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"]))
Run Code Online (Sandbox Code Playgroud)
问题:如何通过传入来设置 2 个元素?
var s = Mapper.Map<Order, NewOrder>(order, opts => opts.Items["Pricing"] = "A"**********missing code**************);
Run Code Online (Sandbox Code Playgroud)
opts =>
{
opts.Items["Pricing"] = "A";
opts.Items["Markup"] = 12;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2247 次 |
| 最近记录: |