Linq To SQl System.Data.linq.EntitySet. Get child object from filtered parent object RRS feed

  • Question

  • I have a wpf project that uses linq to sql. I am currently working on embedding a SQL report to the app and need to be able to pass datasources from code to the report.  I have a ParentTable and a ChildTable in my datacontext

    I am filtering the ParentTable by doing:


    var dsParent = (dc.Parents).Where(r=>r.ParentID=="ParentID");

    and then passing then creating the rdsParent ReportDataSource:



    dsRequest = new ReportDataSource("dsParent",dsParent);

    now I need to also pass the corresponding data in childTable  as another datasource to the report. I know I need to use the and I can see the childTable EntitySet when I look into the dsParent object, but could not figure out how to get that as an oject to pass to the report.

    Here is a complete snippet of the actual code:


    ReportViewer rptViewer = new ReportViewer();

    rptViewer.ProcessingMode =


    rptViewer.LocalReport.ReportPath =




    ReportParameter[] p = new ReportParameter[1];

    p[0] =

    new ReportParameter("RequestID", CurrentFilters.SelectedRequestID, true);





    var dsrequest = (dc.Requests).Where(r=>r.RequestGUID==CurrentFilters.SelectedRequestGUID);


    ReportDataSource dsRequest = new ReportDataSource("dsRequest",dsrequest);



    //How do I get the child data from the parent object???




    rptViewer.BackColor = System.Drawing.



    winFormHost.Child = rptViewer;


    Thanks for any help,

    Tuesday, June 16, 2009 8:48 PM