The SelectMany


Picture this. You have an entity called company which has a list of Employees.  Your given a collection of Companies and you need to get all the employees in the collection.  here’s a one line way of doing it.

var companies= context.Comapny.Select(item => item); // Now you have a list of companies

var allEmployeList=companies.SelectMany(company => company.Employes);

Advertisements

One thought on “The SelectMany

  1. Impressive!
    dint understand what the bottom strip of buttons supposed to do? display related discussions from the archives?
    overall a good initiative.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s