Robbie Dee
Robbie Dee

Reputation: 1977

How to change the display order of properties within an object passed to a method (WCF)

I have a couple of service methods that take an object as a parameter. In the WCF Test Client, the object's properties are displayed in alphabetical order. It would be expedient if we could list certain properties together. Is there a way to do this with an attribute or such like?

Upvotes: 1

Views: 833

Answers (1)

user3021830
user3021830

Reputation: 2924

You can use the DataMember attribute with Order parameter as:

[DataContract]
public class SomeAddress
{
   [DataMember(Order=0)]
   public string FirstName;

   [DataMember(Order=1)]
   public string LastName;
}

The original answer and more detail can be found here.

Upvotes: 3

Related Questions