My application accesses a mongodb using the .net c# driver.
My data structure looks like this:
{
"_id" : ObjectId("53d97351e37f520a342e152a"),
"Name" : "full question test 2",
"keywords" : ["personality", "extraversion", "agreeableness"],
"Questions" : [{
"type" : "likert",
"text" : "question 1",
},
{
"type" : "likert",
"text" : "question 2",
}]
}
What I want to do is to select only the type column from the questions array.
Here is my linq code now:
from e in collection.AsQueryable<scales>()
where e.Name == "full question test 2"
select new { e.Id, e.Name, e.Questions}
This returns all the question properties (both type and text). I want just the type. I can do this by saying something like e.Questions[0].text,e.Questions[1].text.
But the number of questions varies from file to file, so I'd love a solution that doesnt require this manual coding.
Open to ideas!