public TodoSpec Build(TodoQueryParams request) { var specs = new List <TodoSpec>(); specs.Add(BuildInclude(request.Include)); specs.Add(BuildExclude(request.Exclude)); specs.Add(BuildDue( request.Overdue, request.HasDueDate, exactly: request.Due, begin: request.DueAfter, end: request.DueBefore )); specs = specs.Where(x => x != null).ToList(); if (specs.Count() < 1) { return(Spec.All <Todo>()); } return(specs.Aggregate((spec, next) => spec.And(next))); }