1
    [OperationContract]
    [WebGet(RequestFormat = WebMessageFormat.Json)]
    public MyEmployee DoWorksINGLE()
    {

            return new MyEmployee("Bad", "Munner");


    }
 [DataContract]
    public class MyEmployee
    {
        public string FirstName = "";
        public string LastName = "";
        public MyEmployee(string F, string L)
        {
            FirstName = F;
            LastName = L;
        }
    }

I get following out put.

{"d":{"__type":"MyService.MyEmployee:#efleet"}}

Only the name of object not the values. can someone help?

1 Answer 1

1

I believe the JSON serializer only works against properties and not fields and they need to be marked with the DataMember attribute. Try converting the FirstName and LastName fields to properties and see if that fixes the problem.

[DataContract]
public class MyEmployee
{
    [DataMember]
    public string FirstName {get;set;}
    [DataMember]
    public string LastName {get;set;}
    ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

if i want to return a list of object of Entity Framework type.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.