I am trying to await an asynchronous operation inside a select statement which is inside another select statement.
var result = someList
.Select(table => new Table
{
Columns = table.Select(async column => new Column
{
Constraints = await GetColumnConstraints()
})
})
.ToList();
The "problem" here is that the nested select statement returns a list of tasks. Normally we would use Task.WhenAll() to await all of the tasks. So the easiest thing to do would be to change the type of Columns from List<Column> to List<Task<Column>>, then use SelectMany() to fetch every Task and await them. But I cannot change the datatype of Columns.
How can I achieve such thing? I could not find any solution which doesnt involve Task.WhenAll()