Chuck Savage
Chuck Savage

Reputation: 11955

DTO property attributes

I'm connecting to a service using ServiceStack that I have no control on:

I have a DTO like:

public class Request
{
    public string Property1 { get; set; }
}

But the service is expecting a request like {"Property 1":"value"} note the space between the word Property and the 1. Is there an attribute that I can use to set the name to the property that gets transmitted to the server? Something like the following would be helpful:

public class Request
{
    [Name("Property 1")]
    public string Property1 { get; set; }
}

Upvotes: 1

Views: 2815

Answers (1)

Chuck Savage
Chuck Savage

Reputation: 11955

Pull Request #51 Added the following as a result of this issue request.

[DataContract]
public class Request
{
    [DataMember(Name = "Property 1")]
    public string Property1 { get; set; }
}

Upvotes: 1

Related Questions