Posted 27 December 2017, 12:34 am EST
I have been trying to use entity framework to populate the recordset datasource of the report. I have written two methods that change the recordset. The first uses entity directly and populates the master report but throws an error in the sub-report.
public C1FlexReport BuildSubReport2()
{
// example using recordset
C1FlexReport report = new C1FlexReport();
List<CLIENT1> clients;
List<Parcel> parcels;
using (ClientContext context = new C1Report_Example.ClientContext())
{
clients = context.CLIENT1.Where(a => a.ID.StartsWith("AA")).ToList();
parcels = context.Parcel.Where(a => a.ID.StartsWith("AA")).ToList();
}
report.Load("TestReports.flxr", "TestReport1");
report.DataSource.Recordset = clients;
SubreportField field = (SubreportField)report.Fields["Field1"];
C1FlexReport subReport = field.Subreport;
subReport.DataSource.Recordset = parcels;
//report.Render();
//report.Print();
return report;
}
The second uses entity and creates a datatable (using the MoreLinq extension) and does not throw and error.
public C1FlexReport BuildSubReport4()
{
// example using recordset
C1FlexReport report = new C1FlexReport();
DataTable clients;
DataTable parcels;
using (ClientContext context = new C1Report_Example.ClientContext())
{
clients = context.CLIENT1.Where(a => a.ID.StartsWith("BB")).ToDataTable<CLIENT1>();
parcels = context.Parcel.Where(a => a.ID.StartsWith("BB")).ToDataTable<Parcel>();
}
report.Load("TestReports.flxr", "TestReport1");
report.DataSource.Recordset = clients;
SubreportField field = (SubreportField)report.Fields["Field1"];
C1FlexReport subReport = field.Subreport;
subReport.DataSource.Recordset = parcels;
//report.Render();
//report.Print();
return report;
}
I have attached screenshots of the error and a functioning report. Am I doing something wrong?