           query = query.Where(task =&gt; task.AssignedPerson.Id == assignedPersonId.Value);
        }

        if (state.HasValue)
        {
            query = query.Where(task =&gt; task.State == state);
        }

        return query
            .OrderByDescending(task =&gt; task.CreationTime)
            .Include(task =&gt; task.AssignedPerson) //Include assigned person in a single query
            .ToList();
    }
}</pre>

<p><strong>TaskRepository</strong> is derived from <strong>SimpleTaskSystemRe