c# 序列化XML文件时,子类的名称命名

    [XmlRoot(ElementName = "product")]
    public class WMS_Query_ProductInfo
    {
        public string skuCode { get; set; }
        public float normalQuantity { get; set; }
        public float defectiveQuantity { get; set; }
        public float averageWeight { get; set; }
        public int? lineNo { get; set; }
        [XmlArray("batchs"), XmlArrayItem("batch")]
        public List<WMS_Query_Batch> batchs { get; set; }
    }
    public class WMS_Query_Batch
    {
        public string fixStatusCode { get; set; }
        public DateTime? productionDate { get; set; }
        public DateTime? expiryDate { get; set; }
        public string packCode { get; set; }
        public string uomCode { get; set; }
        public decimal? quantity { get; set; }
    }
上面两个类序列化后的文件如下:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<product>
    <skuCode>ddd</skuCode>
    <normalQuantity>0</normalQuantity>
    <defectiveQuantity>0</defectiveQuantity>
    <averageWeight>0</averageWeight>
    <lineNo p2:nil="true"
        xmlns:p2="http://www.w3.org/2001/XMLSchema-instance" />
        <batchs>
            <batch>
                <productionDate p4:nil="true"
                    xmlns:p4="http://www.w3.org/2001/XMLSchema-instance" />
                    <expiryDate>2018-05-03T15:38:03.2177502+08:00</expiryDate>
                    <packCode>ddf</packCode>
                    <uomCode>dd</uomCode>
                    <quantity>1212</quantity>
                </batch>
            </batchs>
        </product>

关键点:
        [XmlArray("batchs"), XmlArrayItem("batch")]
        public List<WMS_Query_Batch> batchs { get; set; }

序列化的代码如下:

            WMS_Query_ProductInfo product = new WMS_Query_ProductInfo();
            product.skuCode = "ddd";
            product.batchs = new List<WMS_Query_Batch>();
            product.batchs.Add(new WMS_Query_Batch { expiryDate = DateTime.Now, packCode = "ddf", quantity = 1212, uomCode = "dd" });
            string str = XmlUtil.Serializer(product);
        public static object Deserialize(Type type, string xml)
        {
            try
            {
                using (StringReader sr = new StringReader(xml))
                {
                    XmlSerializer xmldes = new XmlSerializer(type);
                    return xmldes.Deserialize(sr);
                }
            }
            catch (Exception e)
            {
                Log.Log4net.Error(e.Message);
                return null;
            }
        }