无法序列化System.Nullable`1 [System.Decimal]类型的成员'XXX'.XmlAttribute/XmlText不能用于编码复杂类型

Boo*_*ang 8 c# subsonic web-services

使用Web服务时出现以下错误:无法序列化System.Nullable`1 [System.Decimal]类型的成员'XXX'.XmlAttribute/XmlText不能用于编码复杂类型.

我理解错误并在此博客上找到了解决方案:http: //www.jamesewelch.com/2009/02/03/how-to-serialize-subsonic-objects-with-nullable-properties/#more-827

我想使用解决方案2,正如您在博客上的评论中所看到的,我没有太多运气.我正在使用ExcuteTypeList来恢复数据.

任何指针或帮助都会很棒.

谢谢

NET*_*ET3 13

您需要删除[XmlAttribute]并将[XmlElement]应用于XXX字段.

[XmlElement(IsNullable = true)] public decimal? XXX;

public bool ShouldSerializeXXX()
{
   return XXX.HasValue;
}
Run Code Online (Sandbox Code Playgroud)