I am developing an asp.net mvc 5 web application. There is a class library only for telerik reports[no trdx]. I am using TypeReportSource to resolve report and NeedDataSource event of report file to fetch data from database. In the whole project i am using constructor injection(structuremap) technique but here Constructor injection is not working as telerik report only supports parameterless constructor.
How to pass data to DataSource of the report? I do not want to add separate IoC container for the class library as it is shared by multiple project with separate configuration.
In "Telerik Report Library" mode, the every report are composed by 3 files by default. Let's say i create a report named "ProductReport" in report project. it will generate ProductReport.cs, ProductReport.Designer.cs, ProductReport.resx
Following is the "ProductReport.cs" code:
public partial class ProductReport : Telerik.Reporting.Report
{
public ProductReport()
{
//
// Required for telerik Reporting designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
}
I think one of the option is to add another constructor with parameter(s) which you want to inject in to Report instance, include the data source, and remember to call "InitializeComponent()".
Another good side of this solution is, it will not impact the report designer usage, and the modification of the report items by designer itself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With