Nested linq queries

So linq queries are something I like, but there was something I didn't knew how I should do a nested query. But a few days ago I saw an example of it so thought i should write something about it.

 

Exemple:

from item in list from subitem in item.SubItems select subitem

 

Hope somebody has use of this to :D

 

Comments

Add comment

Name:

Mail:

Website:

Comment:


<< [1] >>
  • 1 years ago by JonW

    The concept is useful if you project your own presentation object with EF for example. In that way you can query multiple parts of your domain without using string and -  .Include("NestedClass")    <-- *yuck!

    Like this

    from item in list from subitem in item.SubItems select new presentationitem() with {.prop1 = item.prop1, .prop2 = subitem.prop2}

    :D


    Reply

    << [1] >>