开发者

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 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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜