user1025901
user1025901

Reputation: 1909

Unable to set values to the data members of Datacontract embedded inside Member Contract from client

I have a message contract as under

 [MessageContract]
    public class PartnerLogViewRequest
    {
        [MessageBodyMember(Order = 0)]
        public PartnerLogView PartnerViewLog { get; set; }
    }

And the data contract as under

[DataContract]
    public class PartnerLogView
    {
        public int PartnerViewLogId { get; set; }
        public string URL { get; set; }
        public string ClientIPAddress { get; set; }
        public DateTime CreationDate { get; set; }
    }

So the data contract is exposed as a property from the message contract.

Now I have created the client proxy. And want to access the properties of the data contract but could not...

My attempt

 PartnerLogViewRequest request = new PartnerLogViewRequest();
 request.PartnerViewLog.ExtensionData

Instead of properties to appear, some "ExtensionData" is coming...

What I am missing and how to assign values to the properties of PartnerLogView?

Thanks in advance

Upvotes: 0

Views: 405

Answers (1)

NoviceProgrammer
NoviceProgrammer

Reputation: 3365

You are missing the [DataMember] attribute. I am not sure if you missed it in your query, but you havent created an object for PartnerLogView.

PartnerLogView partnerLogView = new PartnerLogView();

partnerLogView.PartnerViewLogId =0;
...
...

PartnerLogViewRequest request = new PartnerLogViewRequest();
request.PartnerViewLog=partnerLogView;

Upvotes: 1

Related Questions