title: Return an object in C#
body: <p>I have a method that gets a list of people from the database using aspnet boilerplate framework. Since adding the include line I get the error message:</p>
  
  <blockquote>
    <p>Specified cast is not valid</p>
  </blockquote>
  
  <p>Here is the full error message:</p>
  
  <p>Specified cast is not valid</p>
  
  <p>Here is the c# method:</p>
  
  <pre><code>public ListResultDto&lt;PersonListDto&gt; GetPeople(GetPeopleInput input)
  {
      var persons = _personRepository
          .GetAll()
          .Include(p =&gt; p.Phones)
          .WhereIf(
              !input.Filter.IsNullOrEmpty(),
              p =&gt; p.Name.Contains(input.Filter) ||
                      p.Surname.Contains(input.Filter) ||
                      p.EmailAddress.Contains(input.Filter)
          )
          .OrderBy(p =&gt; p.Name)
          .ThenBy(p =&gt; p.Surname)
          .ToList();
  
      return new ListResultDto&lt;PersonListDto&gt;(ObjectMapper.Map&lt;List&lt;PersonListDto&gt;&gt;(persons));
  }
  </code></pre>
  
  <p>Any ideas on what I need to do to resolve the issue?</p>