Try the following:
var result = personRepository.Query .Where(person => person.Name.Contains("off")) .SelectMany(person => person.Orders) .Sum(order => order.Sum);
If this solution throws an ArgumentNullException when there are no selected orders, try this two-step solution:
var orders = personRepository.Query .Where(person => person.Name.Contains("off")) .SelectMany(person => person.Orders); var result = orders.Any() : orders.Sum(order => order.Sum) ? 0;
source share