I have a nested document structure like:
[
{
"id": "parent1",
"children": [
{
"id": "child1",
"foo": "bar"
},
{
"id": "child2",
"foo": "bar"
},
{
"id": "child3",
"foo": "bar"
}
]
},
{
"id": "parent2",
"children": [
{
"id": "child4",
"foo": "bar"
},
{
"id": "child5",
"foo": "bar"
}
]
}
]
I am able to write the following query in SQL syntax:
SELECT child, parent.id
FROM parent
JOIN child in parent.children
This gets me the following result:
[
{
"child": {
"id": "child1",
"foo": "bar"
},
"id": "parent1"
},
...
]
I wrote a similar query in LINQ using SelectMany clause as follows, but it throws an error stating SelectMany can have only 2 arguments.
collection.SelectMany(
parent => parent.children,
(parent, child) => new { child, parent.id });
SelectManyoverload? Exact error message? In case of yes, the answer of dasblinkenlight could solve it.