我有两个从实体框架导入的 XML 可序列化类 Parent-Child。总结成这样
[Table("OecPreorden")]
[DataContract]
public partial class OecPreorden
{
public OecPreorden()
{
OecPreordenProductos = new HashSet<OecPreordenProductos>();
}
[DataMember(IsRequired = false, Order = 1, Name = "ProductosComerciales")]
public virtual ICollection<OecPreordenProductos> OecPreordenProductos { get; set; }
}
[Table("OecPreordenProductos")]
[DataContract]
public class OecPreordenProductos
{
public OecPreordenProductos()
{
}
[XmlIgnore()]
public int Id { get; set; }
[DataMember]
[Required]
public long IdPromocion { get; set; }
[DataMember]
[Required]
public long IdProductoComercial { get; set; }
[DataMember]
[Required]
public long NroOrden { get; set; }
public int PreOrden_id { get; set; }
public virtual OecPreorden OecPreorden { get; set; }
}
当我看到 XML 时,它是这样显示的
<dir:ProductosComerciales>
<!--Zero or more repetitions:-->
<dir:OecPreordenProductos>
<dir:IdPromocion>?</dir:IdPromocion>
<dir:IdProductoComercial>?</dir:IdProductoComercial>
<dir:NroOrden>?</dir:NroOrden>
</dir:OecPreordenProductos>
</dir:ProductosComerciales>
因为它有零次或多次重复......它显示标题正确
<dir:ProductosComerciales>
我要更改的是迭代的标题..
<dir:OecPreordenProductos>
当我设置
[XmlRoot("AAA")]
public class OecPreordenProductos
或者
[XmlType(TypeName = "AAA")]
public class OecPreordenProductos
它不起作用,它仍然显示类名。
如何更改重复类的名称?