C# VisualStudio:使用整数在xsd问题上生成代码

C# VisualStudio:使用整数在xsd问题上生成代码,c#,xsd,code-generation,integer,xsd.exe,C#,Xsd,Code Generation,Integer,Xsd.exe,谁能告诉我,为什么xsd中的整数元素在字符串字段中转换 <xs:element name="OwnerID" type="xs:integer"/> 我的第一个假设是所有字段都是实数数据类型属性的字符串,这是不对的-日期被解释为日期,布尔值被解释为布尔值-整数有什么错 提前谢谢 你需要这样的东西: <xs:element name="OwnerID" > <xs:simpleType> <xs:restriction base=

谁能告诉我,为什么xsd中的整数元素在字符串字段中转换

<xs:element name="OwnerID" type="xs:integer"/>
我的第一个假设是所有字段都是实数数据类型属性的字符串,这是不对的-日期被解释为日期,布尔值被解释为布尔值-整数有什么错


提前谢谢

你需要这样的东西:

<xs:element name="OwnerID" >
    <xs:simpleType>
        <xs:restriction base="xs:int" />
    </xs:simpleType>
</xs:element>

sq33G的答案是正确的,但我想补充一点,那就是您原始XSD元素的原因

<xs:element name="OwnerID" type="xs:integer"/>


转换为字符串是因为per,xs:integer表示任何整数值。由于不限于32或64位数字,而且C#中没有可以处理无界整数的数字数据类型,反序列化程序正在选择字符串类型,因为它是唯一可以安全处理此值的类型。

我们几乎同时得到了解决方案-)只需将xs:integer替换为xs:intI就足够了,我需要自己更正-我错误地记住了该行为。整数确实映射到System.Decimal类型
<xs:element name="OwnerID" type="xs:integer"/>