对于十进制/ int / long反序列化,当属性为空时失败

编程入门 行业动态 更新时间:2024-10-27 14:18:31
本文介绍了对于十进制/ 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<testi: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]

公共小数?测试 {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 <testi: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反序列化,当属性为空时失败

本文发布于:2023-11-08 22:16:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1570598.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:为空   属性   序列化   十进制   int

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!