I would like to set the Datasource of my report to a business object (ObjectDataSource) that has all of it's data already populated. ie. when the report requests the data, it does not need to go out to any datastore to retrieve it, the object is already initialized with the data it requires.
I have a class with a method that returns a list of objects.
public
class
SummaryReportData
{
public
List<SummaryData> RetrieveData( )
{
return
SummaryDataList;
}
public
List<SummaryData> SummaryDataList {
get
;
set
; }
}
When I am launching my report, I am retrieving the data I would like to display from my data service, and setting it on the object that the report will be requesting the data from. Like so:
var report =
new
MonthlySummaryReport();
var dataObject =
new
SummaryReportData();
dataObject.SummaryDataList = someDataService.GetSummaryReportData(100);
report.DataSource = dataObject;
ReportToDisplay =
new
InstanceReportSource();
ReportToDisplay.ReportDocument = report;
(this is a wpf application, so I am databinding the 'ReportToDisplay' report source to the viewer. This works as expected)
I then have the report setup to use an ObjectDataSource, Business Object set to "SummaryReportData", and the DataMember is set to "RetrieveData".
What ends up happening is, even though I have pre-initialized the SummaryReportData object with my data, when the report renders it is creating a new instance of that object, calling it's constructor, and then calling the "RetrieveData" method, which returns an empty list.
How do I get the report to use the object instance I am supplying it, instead of recreating it when it launches?