What's the proper way to run an async function in a LINQ where statement?

Viewed 49

What's the correct way to write the following

var orders = OrigOrders.Where(async o => await o.Validate(o));

I keep getting errors like the following: Cannot convert lambda expression to delegate function<order, bool>...

As such I'm writing it like this but this seems superfluous

var Orders = new List<Order>();
foreach(var o in OrigOrders)
{
     if (await Validate(o)) orders.Add(co);
}
0 Answers
Related