var expr =
  from c in customers
  join o in (
      from c in customers
          from o in c.Orders
          join p in products
                on o.IdProduct equals p.IdProduct
          select new { c.Name, OrderAmount = o.Quantity * p.Price }
      ) on c.Name equals o.Name
      into customersWithOrders
  select new { c.Name,
            AverageAmount = customersWithOrders.Average(o =>
o.OrderAmount) };
