The main thing you are trying to achieve is reusing the predicate that defines the value of Attending . This can be done by storing the expression in the readonly variable, accessible to those who need it, for example, in the static class ExpressionConstants .
public static readonly Expression<Func<Registration, bool>> IsAttending = r => r.Status == RegistrationStatus.Paid || r.Status == RegistrationStatus.Assigned || r.Status == RegistrationStatus.Completed;
Then you can do
var attendees = db.Registrations.Where(ExpressionConstants.IsAttending).ToList();
And used in the subquery:
ProductTotals = db.Products.Where(p => p.EventID == ev.Id).Select(p => new ProductSummaryViewModel { ProductID = p.ProductID, ProductName = p.Name, Registrations = p.Registrations.AsQueryable()
AsQueryable() necessary because p.Registrations is probably an ICollection .
source share