The sample class I add earlier was
public class Author:Entity
{
public virtual string name { get; set; }
public string dob { get; set; }
}
and the response on getting list of authors was
[
{
"id": "5a2983589157cf906c39e808"
},
{
"id": "5a29899fcef3e85b9c427dd9"
},
{
"id": "5a29920fc9ea2c7a38f45085"
}
]
After adding DataMember to each property like below
public class Author:Entity
{
[DataMember]
public virtual string name { get; set; }
[DataMember]
public string dob { get; set; }
}
I was able to get the name and dob as part of the response
[
{
"name": null,
"id": "5a2983589157cf906c39e808"
},
{
"name": "Alayo Bolt",
"id": "5a29899fcef3e85b9c427dd9"
},
{
"name": "Alayo Bolt",
"id": "5a29920fc9ea2c7a38f45085"
}
]
Must I add the attribute [DataMember] to every field of my POCO classes before it could map to a field in the container document?