WSDL time format is ignored from Visual Studio

后端 未结 1 1913
[愿得一人]
[愿得一人] 2021-01-25 01:06

A WSDL file from a customer specifies the time data type using this syntax:

相关标签:
1条回答
  • 2021-01-25 01:18

    I think there is no good solution, so you have to edit the auto generated code.

    Create a partial class of the auto generated code and add a string property with the correct formatting in it:

    [System.Xml.Serialization.XmlElementAttribute(Form = System.Xml.Schema.XmlSchemaForm.Unqualified, 
     DataType = "string", ElementName = "I_TIMETO")]
    public string I_TIMETO_STR
    {
        get
        {
            return this.i_TIMETOField.ToString("HH:mm:ss");
        }
        set
        {
            this.i_TIMETOField = DateTime.ParseExact(value, "HH:mm:ss", CultureInfo.InvariantCulture);
        }
    }
    

    Now go to the auto generated property and add a XmlIgnore:

    [System.Xml.Serialization.XmlIgnore] 
    public System.DateTime I_TIMETO{...
    
    0 讨论(0)
提交回复
热议问题