tags:

views:

82

answers:

2

Hello and thanks for any assistance

In my WCF Service I have a property declared as such:

public string PropertyName { get { return propertyName; } set { propertyName = value; } }

In my Client, when i add a service reference to the service, the imported .cs file has the same property, except it has lost it's casing, as such:

[System.Runtime.Serialization.DataMemberAttribute(IsRequired=true)] public string propertyName { get { return this.propertyNameField; } set { this.propertyNameField = value; } }

(Notice the lower case 'p' on 'propertyName')

Is there anything I can do so that consumers actually get the property with the intented Casing, ie: PropertyName not propertyName?

Thanks, Steven

A: 

Have you tried explicitly setting the Name in the DataMember? For example:

[DataMember(Name="PropertyName")]
public string PropertyName { get { ... } set { ... } }
Scott Anderson
Hello Scott. I just gave your method a try, sorry but it didn't work. Thanks for the help though. Steven
stevenrosscampbell
Hello Scott. My apologies. Your suggestion did work. The problem was that I didn't have the: [DataContract(Name = "Account", Namespace = "http://companyname/webservices/schema/account")] attribute arround the class. when I added it everything worked as expected. Thanks,Have a good one. Steven
stevenrosscampbell
A: 

Do you have the DataContract attribute in place correctly? Also make sure that you're applying the DataMember to the property and not the private string.

[DataContract]
public class DataObject {

    string propertyName;

    [DataMember]
    public string PropertyName {
        get { return propertyName; }
        set { propertyName = value; }
    }
}

The full code of the class would be helpful.

Mikko Rantanen