Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Unable to get individual properties from collection document after inheriting from Entity #56

Description

@huzaynbolt

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions