How to select in element Linq (Entity framework)

I am using entity framework for my database and select or / and enable expansion so much data, so basically I am looking for a query like this:

var result = DbContext.products
            .select(p=> new {
             p.Id,
             p.Name,
             p.Notes
             .select(n=> new {
                n.date,
                n.text
                             }
            });

      

+3


source to share


1 answer


You can use this code:



var result = DbContext.products
        .select(p=> new {
                         Id = p.Id,
                         Name = p.Name,
                         SelectedNodes = p.Notes.select(n=> 
                                             new {n.date, n.text}).ToList()                            
        });

      

+5


source







All Articles