Telerik Reporting ObjectDataSource with dependency injection

I am developing an asp.net mvc 5 web application. There is a telerik [no trdx] report-only class library. I am using TypeReportSource to resolve the report and the NeedDataSource event of the report file to retrieve data from the database. Throughout the project, I use the constructor constructor (structmap), but embedding the constructor does not work here, since the telerik report only supports the constructor without parameters.

How to transfer data to a DataSource report? I do not want to add a separate IoC container for the class library, since it is shared by several projects with a separate configuration.

+5
source share
1 answer

In the Telerik Message Library mode, each report consists of 3 files by default. Let's say I create a report called "ProductReport" in the draft report. it will generate ProductReport.cs, ProductReport.Designer.cs, ProductReport.resx

Below is the code "ProductReport.cs":

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 options is to add another constructor with the parameters that you want to insert into the Report instance, include the data source and do not forget to call "InitializeComponent ()".

Another good side of this solution is that it will not affect the use of the report designer and the modification of report elements by the designer.

+1
source

Source: https://habr.com/ru/post/1216286/


All Articles