对于十进制/ int / long反序列化,当属性为空时失败 [英] For decimal / int / long deserialization is failing when property is empty

查看:136
本文介绍了对于十进制/ int / long反序列化,当属性为空时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Team,

我们有XML格式的WCF服务和请求。在XML请求中,其中一个属性采用以下格式< test />。

We have WCF service and request in XML format. In the XML request one of the attribute is coming in this format <test/>.

以下是数据成员。它以十进制格式和可空。但是 < test /> xml属性抛出desensitization错误。如果我们将xml属性更改为 < test  i:nil =" true" />有用。这个问题只有
数据类型decimal / int / long等。有数据类型字符串< test />它运作良好。

Below are the data member. Its in decimal format and nullable. But with <test/> xml attribute its throwing desensitization error. If we change the xml attribute to <test i:nil="true" /> it works. This issue is only with data type decimal/int/long etc..With data type string <test/> it works well.

[DataMember]

[DataMember]

公共小数?测试

  &NBSP; &NBSP; &NBSP; {get;组; }

public decimal? test
        { get; set; }

但我需要数据类型为decimal / int / long的解决方案。 因为我们没有以这种格式收到< test  i:nil =" true" />从上游。他们正在发送< test />。 如何处理?

But I need the solution for data type decimal/int/long.  Because we are not receiving in this format <test i:nil="true" /> from upstream. They are sending <test />.  How to handle this ?

谢谢和问候,

Santosh Hegde

Santosh Hegde

推荐答案

尝试这样做,看看它是否解决了你的问题(我目前还没有编译器来检查)。

Try make it like this and see if it solves your problem (I currently don't have compiler to check).

[DataMember(IsRequired = false)]
public decimal? test { get; set; }


这篇关于对于十进制/ int / long反序列化,当属性为空时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆