none
using LINQ to flatten one to many data.. RRS feed

  • Question

  • Hi, suppose i have the following

    public class WorkBook{
         IList<WorkSheet> WorkSheets {get; set;}
    }
    
    static void main{
         IList<WorkBook> _workBooks = GetAllWorkBook(...); (//some function that returns a list of workbooks; ea workbook may have one or more worksheets)
         
         //linq to extract all Worksheets
         IEnumerable allWorkSheets = from WorkBook w in _workBooks select _workBooks.WorkSheets;
    }
    


    The problem with the above code is that allWorkSheets is actually an enumberable list of list.  I'd like instead to ensure that allWorkSheets is truly an enumerable list of WorkSheet objects.  How can that be done using LinQ, if possible?

    Thursday, April 30, 2009 7:05 PM

Answers