var outline = Grandparents.Select(
x =>
x.Parents.Select(
y =>
y.Children.Aggregate(string.Empty, (current, child) => string.Format("{0}{1},{2},{3},{4}\n",
current, x.Grandparent,
y.Parent,
child.Name,
child.Age))));
Grandparents is a class with two members:
string Grandparent
List<Parent> Parents
Parents is a class with two members:
string Parent
List<Child> Children
Child is a class with two members:
string Name
int Age
I want to use Linq to produce a string that I'll write to at text file, for example:
Grandpa Walter, Parent William, Child Chris, Age 11
Grandpa Walter, Parent Sue, Child Alice, Age 7
Grandpa Walter, Parent Sue, Child Sam, Age 7
Grandpa Eugene, Parent David, Child Joe, Age 17
The above code produces an IEnumearable of IEnumerable of String. I want to produce just a "string"