Use LLBLgen objectmodel with Telerik reporting

Posts   
 
    
dotprof
User
Posts: 20
Joined: 19-Feb-2010
# Posted on: 12-Mar-2011 09:54:17   

Hello, The Telerik reporting tool uses a own set of datasources: Entity, SQL, Object and Cube. These classes are not related to ASP.Net objects, they inherit the base class Telerik.Reporting.Datasource

Can you refer to a sample or documenation what is the best approach to use LLBLgen pro with the Telerik reporting using the following assumptions:

  • Use a Entitycollection, including child objects in the report without using helper classes to transform the collection to a strongly type dataset
  • Be able to use the collection in the reporting tool using intellicense, so the fields of the entitycollection can be used in design mode to add or edit fields on the report.

I know this is partly a LLBlgen matter, and probably mostly a Telerik matter, because they don't use the standard asp.net object datasource.

I hope someone of you has already walked this path so I don't need to reinvent the wheel confused

Thanks in advance

dotprof
User
Posts: 20
Joined: 19-Feb-2010
# Posted on: 12-Mar-2011 20:14:28   

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 wink . 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.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Mar-2011 20:42:31   

Yes, with Telerik that is a very natural way to do it. I also tend to create my own methods that create retrieve the data and pass it to the reporting control. That way Telerik doesn't ask for data, I pass such data to the control so I have the control of the fetch.

David Elizondo | LLBLGen Support Team