Search code examples
linqentity-framework-4riawcf-ria-services

How to get object collection from another collection?


Suppose I have a collection defined as:

IEnumerable<Employee> Employees;

Entity Employee has property Person. I have loaded Employees from Ria service including Person with eager-loading. Now I want to get the collection of Person from Employees, something like

IEnumerable<Person> People = Employees.Person;

How to use Linq to get all Person? any other solution for this case?


Solution

  • Unless I'm missing something, it should be as easy as (assuming Person isn't another collection):

    var persons = Employees.Select(e => e.Person);