Type没有默认构造函数automapper

时间:2012-03-29 13:53:14

标签: automapper

我遇到了问题:

public class TDocumentation
{
   public XmlElement Summary { get; set; }

   public XmlElement LongDescription { get; set; }

   public XmlAttribute[] AnyAttr { get; set; }
}

...和

public class ProxieTDocumentation
{
    public XmlElement Summary { get; set; }

    ......
}


Mapper.CreateMap<Proxies.TDocumentation, TDocumentation>()

...抛出:

----&GT; System.ArgumentException:类型“System.Xml.XmlElement”没有默认构造函数automapper

如何在另一个上进行映射?

1 个答案:

答案 0 :(得分:1)

我解决了这个问题:

Mapper.CreateMap<XmlElement, XmlElement>().ConvertUsing(item => item != null ? item.Clone() as XmlElement : null);