c# - Select detail from master-detail list using lambda -


below sample data. 2 companies having 2 employees.

list<company> companies = new list<company>  {     new company     {         name = "abc company",         address = "no.1 st. usa",         employees = new list<employee> { new employee { name = "john", age = 30 }, new employee { name = "david", age = 20 } }     },     new company     {         name = "def company",         address = "no.2 st. usa",         employees = new list<employee> { new employee { name = "michael", age = 22 }, new employee { name = "jason", age = 27 } }     } }; 

i try retrieve employees using following syntax:

var employees = companies.select(c => c.employees).tolist(); 

however, gives me

the name 'employees' not exist in current context

when watch @ run time. expected result list<employee> having 4 employees. suggestions appreciated.

you should use selectmany instead of select.

the error show has nothing query. not in right scope when trying watch variable.


Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

IIS->Tomcat Redirect: multiple worker with default -