Did some playing with Telerik Reporting Tool.
Correct me, if I am wrong, but perhaps the best way for reporting purposes is not to use LLBlgenPro (or any other OR-mapper .
Followed this path:
1. Prepare the handcrafted view in the database, including all related entities.
2. If you require dropdown boxes for parameters in the report (e.g. select country) then prepare also the view(s) for the dropdownboxes
3. Wrap each view in a stored procedure with parameters to use.
Build the Telerik report(s) in a seperate project. Don't forget to copy the connectionstring from the app.config to the web.config of your webapplication.
In the project I use a helper class with static methods. For every report I use a static method that can be used in the web control that display's the report.
e.g. helper class:
public static class ReportManager
{
public static IReportDocument GetRptPersonBadge(int userID)
{
RptPersonBadge rpt = new RptPersonBadge();
rpt.ReportParameters.Clear();
Telerik.Reporting.ReportParameter reportParameter1 = new Telerik.Reporting.ReportParameter();
reportParameter1.Type = Telerik.Reporting.ReportParameterType.Integer;
reportParameter1.Name = "UserID";
reportParameter1.Text = "UserID";
reportParameter1.Visible = false;
reportParameter1.Value = userID;
rpt.ReportParameters.Add(reportParameter1);
return rpt;
}
}
Code used in the web control of web page:
ReportViewer1.Report = ReportManager.GetRptPersonBadge(currentUser.UserId );
ReportViewer1.RefreshReport();
Sometimes when designing the report you cann't access certain values because you don't have a Httpcontext. Instead of using the database field directly with a Telerik report object you could also use a helperclass. In the following example an image is embedded in the project. Calling this method in the value of a Telerik PictureBox makes the report work also in design mode. E.g. the database field PhotoImage1 contains the path to an image in your web application:
this.pictureBox1.Value = "= ReportHelper.PhotoImage(Fields.PhotoImage1)"
public static object PhotoImage(object imageName)
{
if (HttpContext.Current == null)
{
Assembly thisAssembly = Assembly.GetExecutingAssembly();
Stream myStream = thisAssembly.GetManifestResourceStream("Dotprof.Reunie.BusinessLayer.Report.about.png");
Bitmap bmp = new Bitmap(myStream);
return bmp;
}
return Convert.ToString(imageName);
}
One might consider rebuilding the report helper class to a factory class that is driven by data from the database, instead of "hardcoding" parametertype's, name's etc. However, since changing the reports always requires designtime in Visual Studio I don't mind changing the helperclass at the same time.