AutoMapper对象集合 [英] AutoMapper Object collections
问题描述
嗨.我注意到您在Automapper上的文章非常好.感谢那.我有一个问题.我正在尝试映射一个与我要映射到的类具有相同布局和签名的类.一切顺利且简单,但当我尝试映射对象集合时除外.例如,当我尝试映射在类中定义的此属性时:
Hi. I noticed your article on Automapper which is very good. Thanks for that. I do have a question. I am trying to map a class which has an identical layout and signature to the class I am trying to map to. All goes well and simple except when I try to map Object collections. For example when I try to map this property defined in the class:
[System.Xml.Serialization.XmlElementAttribute("transaction_history", typeof(TransactionHistory))]
[System.Xml.Serialization.XmlElementAttribute("transfer_value_split", typeof(TransferValueSplit))]
[System.Xml.Serialization.XmlElementAttribute("trust", typeof(Trust))]
[System.Xml.Serialization.XmlElementAttribute("valuation", typeof(Valuation))]
[System.Xml.Serialization.XmlElementAttribute("waiver_of_premium_ind", typeof(YesNo))]
[System.Xml.Serialization.XmlElementAttribute("written_under_trust_ind", typeof(YesNo), IsNullable = true)]
[System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemsElementName")]
public object[] Items
{//You need to add XmlChoiceIdentifierAttribute
get
{
return this.itemsField;
}
set
{
this.itemsField = value;
}
}
我发现它不映射,但与源对象保留在相同的名称空间中.
不知道您对此事有什么想法.
谢谢,
迈克尔
[已删除的个人电子邮件地址-wizardzz]
I find that it does not map but remains in the same namespace as the source object.
I wonder if you have any ideas on this matter.
Thanks,
Michael
[removed personal e-mail address - wizardzz]
推荐答案
我认为将这样的问题发布到原始文章中符合您的最大利益.这将使本文的作者和代码有机会看到问题并回答您.
I think it would be in your best interest to post a question like this to the original article. It will give the author of the article and code an opportunity to see the question and respond to you.
这篇关于AutoMapper对象集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!