none
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:

    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 System.data.linq.EntitySet 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 =

    ProcessingMode.Local;

    rptViewer.LocalReport.ReportPath =

    "rptRequestDetail.rdlc";

    rptViewer.LocalReport.DataSources.Clear();

     

    ReportParameter[] p = new ReportParameter[1];

    p[0] =

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

    rptViewer.LocalReport.SetParameters(p);

     

     

     

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

     

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

     

    rptViewer.LocalReport.DataSources.Add(dsRequest);

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

     

    //rptViewer.LocalReport.DataSources.Add(dsRequestDetail);

     

    rptViewer.BackColor = System.Drawing.

    Color.White;

    rptViewer.RefreshReport();

    winFormHost.Child = rptViewer;

     



    Thanks for any help,
    ck

    Tuesday, June 16, 2009 8:48 PM