Suppose I have a collection defined as:
IEnumerable<Employee> Employees;
Entity Employee has property Person. I have loaded E开发者_如何学Gomployees 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?
Unless I'm missing something, it should be as easy as (assuming Person
isn't another collection):
var persons = Employees.Select(e => e.Person);
Try the following
IEnumerable<Employee> collection = ...;
IEnumerable<Person> persons = collection.Select(x => x.Person);
精彩评论