I have the following classes:
public class Owner
{
public string Id { get; set; }
public string Name { get; set; }
}
public class Main
{
public s
You should use SelectMany to flatten a sequence of Main objects:
Projects each element of a sequence to an IEnumerable and flattens the resulting sequences into one sequence.
So it projects each Main object into sequence of FlatList objects and then flattens resulting sequences into one FlatList sequence
var flatList = mainList.SelectMany(m =>
m.Owners.Select(o =>
new FlatList {
Id = m.Id,
Name = m.Name,
OwnerId = o.Id,
OwnerName = o.Name
})).ToList()