This is a migrated thread and some comments may be shown as answers.

Using EntityDataSource generates blank reports with no errors

1 Answer 43 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Siva
Top achievements
Rank 1
Siva asked on 11 Dec 2012, 09:41 PM
I have gone through http://www.telerik.com/help/reporting/entitydatasource.html but am completely stummped. My code generates no errors but all of the reports are coming up blank.

Here is my code:

XAML Element:
<telerik:ReportViewer Name="telerikPersonReport" Height="275" />


LoadTelericReport() is called after the data source and page has been initialized.
public void LoadTelericReport()
{
    Telerik.Reporting.EntityDataSource entityDataSource = new Telerik.Reporting.EntityDataSource();
 
    ReportEntity objectContext = new ReportEntity();
 
    entityDataSource.ObjectContext = objectContext;
    entityDataSource.ObjectContextMember = "Events";
 
    Telerik.Reporting.Report report = new Telerik.Reporting.Report();
    report.DataSource = entityDataSource;
 
    Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
    reportSource.ReportDocument = report;
 
    telerikPersonReport.ReportSource = reportSource;
    telerikPersonReport.RefreshReport();
}

The second part is the class that pulls from the Entity Framework:

public class ReportEntity
    {
 
        Attendance_Tracker ThisData = new Attendance_Tracker();
 
        public ReportEntity()
        {
            ThisData.Attendances.Load();
            ThisData.Attendees.Load();
            ThisData.Events.Load();
            ThisData.Sessions.Load();
        }
 
        public List<EventType> Events()
        {
            var AllEvents = from e in ThisData.Events.Local
                            select new EventType()
                            {
                                EventID = e.EventID,
                                EventName = e.EventName,
                                StartDate = e.StartDate,
                                EndDate = e.EndDate,
                                count = (from a in ThisData.Attendances.Local
                                         where a.Session.Event == e
                                         select a).Count()
                            };
            return AllEvents.ToList();
        }
}

Both sections are run fully, and AllEvents.ToList() is returning a full List<EventType> (if this matters it isn't called until after it has been bound to telericPersonReport.

As far as I can tell the WPF reporting front end just isn't displaying the List<EventType>, but it also isn't throwing an errors which seems strange. Is there something clearly wrong with my code, am I just completely off on how this works?

Thank you all for any directions you can point me in!

1 Answer, 1 is accepted

Sort by
0
Siva
Top achievements
Rank 1
answered on 12 Dec 2012, 05:29 PM
I *think* I figured out my error. It came down to a scoping issue it apears. I moved the "ReportEntity" class into the same model file that stores all of the model data and out of the reporting files. I also didn't have the ReportEntity class public (clearly a huge error). Last I added "[DataObject]" above the ReportEntity class declaration and "[DataObjectMethod(DataObjectMethodType.Select)]" above each of the getter functions. Using DataObject requires adding "using System.ComponentModel;" to the file.

Last note: I had to re-compile (F6) after making any changes to the ReportEntity class before the wizard saw the changes.

My ReportEntity class now looks like this and is seen by the wizard.

 

    [DataObject]
    public class ReportEntity
    {
 
        AttendanceTracker.Attendance_Tracker ThisData = new AttendanceTracker.Attendance_Tracker();
 
        public ReportEntity()
        {
            ThisData.Attendances.Load();
            ThisData.Attendees.Load();
            ThisData.Events.Load();
            ThisData.Sessions.Load();
        }
 
        [DataObjectMethod(DataObjectMethodType.Select)]
        public List<EventType> GetEvents()
        {
            var AllEvents = from e in ThisData.Events.Local
                            select new EventType()
                            {
                                EventID = e.EventID,
                                EventName = e.EventName,
                                StartDate = e.StartDate,
                                EndDate = e.EndDate,
                                count = (from a in ThisData.Attendances.Local
                                         where a.Session.Event == e
                                         select a).Count()
                            };
 
            return AllEvents.ToList();
        }
}
Tags
General Discussions
Asked by
Siva
Top achievements
Rank 1
Answers by
Siva
Top achievements
Rank 1
Share this question
or