none
What is IsRequired and Order keyword usage in wcf RRS feed

  • Question

  • [DataMember(Name="FileType", Order=0, IsRequired=true)]
    [DataMember(Name="localFilename", Order=1, IsRequired=false)]
    public string LocalFileName;
    [DataMember(Name = "remoteFilename", Order = 2, IsRequired = false)]
    public string RemoteFileName;

    what order does ?

    what IsRequired does ?

    Monday, December 26, 2016 8:43 PM

Answers

  • Hi Mou_inn,

    IsRequired and Order are DataMemberAttribute properties. They are usually used in Data Contract Version.

    While developing, you may need to change your DataContract like adding new data members. To prevent break old DataContract communication after adding new data members, you could set IsRequired as false and Order is larger than old Order in old DataContract. As a result, while communicating between old DataContract and new DataContract, Old DataContract would not throw exception even through it does not have new property and this new property would be ignored. After setting Order, the XML of dataContract would not change the exist order of DataMembers, and it will append the Old DataMembers later.

    # 8.In later versions, new data members can be added. They should always follow these rules:

    https://msdn.microsoft.com/en-us/library/ms733832(v=vs.110).aspx

    Best Regards,

    Edward


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Sudip_inn Wednesday, December 28, 2016 9:12 PM
    Tuesday, December 27, 2016 2:10 AM