So, I know that Telerik Reporting has been asked about here before but I'm so close and I just need a nudge. For some unknown reason, Telerik doesn't have the ability to have a Net Core reporting project (something to do with System.Drawing) but you can create a .NET 4.8 project, add the reports and then view those reports from a Net Core 3.1 app. I have that all working. My problem now is DI.
The Core project is Net Core, the Application project is Net Core but the reporting project can only reference NetStandard.
I do have a module for the reporting project that the Mvc then depends on, the report is correctly being resolved using IocManager:
/// <summary>
/// See https://docs.telerik.com/reporting/knowledge-base/how-to-inject-custom-dependency-in-reports-controller-of-dot-net-core-application
/// </summary>
/// <param name="report"></param>
/// <param name="operationOrigin"></param>
/// <param name="currentParameterValues"></param>
/// <returns></returns>
public ReportSource Resolve(string report, OperationOrigin operationOrigin, IDictionary<string, object> currentParameterValues)
{
var reportType = Type.GetType(report);
if (reportType == null) throw new UserFriendlyException($"Could not find a corresponding report for type '{report}'.");
var resolvedReport = (Report)_iocManager.IocContainer.Resolve(reportType);
var reportSource = new InstanceReportSource { ReportDocument = resolvedReport };
return reportSource;
}
But, now that I can view the report - how can I get data from the system?
So, what are the possibilities here?
3 Answer(s)
-
0
Hi @kfrancis
If I understand correctly, you want to access database from your .NET 4.8 app. If so, you can't use existing EF Core layer because it is .NET Core 3.1. You need to create a similar layer to existing EF Core project which targets .NET 4.8. Then, you can use it in your project.
-
0
Actually, it does appear possible to do without doing that by resolving services at runtime:
var patientAppServiceType = Type.GetType("PatientManagement.Patients.PatientsAppService, PatientManagement.Application"); var patientAppService = _iocManager.IocContainer.Resolve(patientAppServiceType) as IPatientsAppService; var result = AsyncHelper.RunSync(() => patientAppService.GetPatientForViewAsync(patientId));
We have now been able to circumvent Telerik's inability to use their report designer on netstandard/netcore projects. I have a version based off the demo that I can share as well.
-
0
Hi @kfrancis
I'm glad that it works :). I'm sure other people will need such a sample. If they do, they can write here and you can help them.
Thanks a lot.