【发布时间】:2015-01-11 02:14:45
【问题描述】:
我在源对象和目标对象之间面临 AutoMapper 的挑战。 我将尝试解释这种情况。 在我的 src 对象上,我有一个字符串,根据它的长度,它应该映射到我的目标对象的多个属性。
class source
{
public int Id {get; set;}
/* some other properties */
public string Value {get; set;}
}
class destination
{
public int Id {get; set;}
/* some other properties with the same name as the source */
public string Value1 {get; set;}
public string Value2 {get; set;}
public string Value3 {get; set;}
}
预期的最大长度为 30 个字符(它可以小于仅映射到两个或一个属性的长度)。因此,每 10 个将映射到每个目标属性。我试图使用 AutoMapper 中的 ResolveUsing 方法,但无法让函数知道我应该带回哪个段。 所以我想忽略这个属性的映射,并在 Automapper 完成其他属性的工作后手动执行此操作
【问题讨论】:
标签: c# visual-studio-2010 automapper automapper-2 automapper-3