0

I'am trying to query a document of the specified objectID from a collection and get the nested array from that document.

Here is the sample of a document from my collection.

{
    "_id" : ObjectId("54f46d20793f2c2dd4eaaa60"),
    "academicQualifications" : [ 
        {
            "degreeCompleted" : "Masters' in other fields",
            "degree" : "Master in Engineering Education",
            "when" : "2010-present",
            "Where" : "WIT, Iloilo CIty",
            "Remarks" : "12 units earned, Ongoing"
        }, 
        {
            "degreeCompleted" : "Masters' in other fields",
            "degree" : "MS Computer Engineering",
            "when" : "1995-200",
            "Where" : "WIT",
            "Remarks" : ""
        }
    ]
}

Here is my entity

 class facultyData 
    {  
        public ObjectId _id { get; set; }
        public List<acadQualifications> academicQualifications { get; set; }  
    }
class acadQualifications
    {
        public ObjectId _id { get; set; }
        public string degreeCompleted { get; set; }
        public string degree { get; set; }
        public string when { get; set; }
        public string where { get; set; }
        public string remarks { get; set; }
    }

So what I wanted to accomplish is, to get the "degree", "when", "where" and remarks values from each item of the array and append them to a string that I will later be used for a table.

Here's what it should look like on a string.

For the degree, "Master in Engineering Education / MS Computer Engineering" the same with when, where, remarks.

5
  • Try printing academicQualifications[x].degreeCompleted It might give you what you want. Commented Mar 9, 2015 at 9:05
  • From your question it is rather unclear what you are trying to accomplish, can you please give a clear example of the output string? Commented Mar 9, 2015 at 9:05
  • @chridam Let's say we have the string for the degree keys, the output should be "Master in Engineering Education / MS Computer Engineering". Each value will append to the string. Commented Mar 9, 2015 at 9:10
  • Refer to stackoverflow.com/a/20662135/897882 Commented Mar 9, 2015 at 9:15
  • @krikara Thanks, I'm trying the solution you gave at this moment. I'm going to post the answer later. +1 Commented Mar 9, 2015 at 10:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.