5

Tôi đã có kinh nghiệm trong việc phát triển báo cáo (SSRS) bằng cách sử dụng tập dữ liệu ado.net. Bây giờ tôi đang làm việc trên một ứng dụng không sử dụng ADO.net nhưng khung thực thể nhưng khung thực thể không trả lại dữ liệu hoặc tập dữ liệu. Tôi muốn biếtDịch vụ báo cáo bằng cách sử dụng Khung thực thể

  1. Có cách nào để sử dụng Bộ sưu tập hoặc đối tượng tùy chỉnh trả về theo khung pháp nhân trong dịch vụ báo cáo không?
  2. Khuôn khổ thực thể bằng cách nào đó trả lại dữ liệu hoặc tập dữ liệu.

Hoặc tôi nên tạo dữ liệu/tập dữ liệu từ bộ sưu tập được trả về theo khung thực thể theo cách thủ công.

Để lưu nội dung, tôi nhận được kết quả bằng cách thực hiện quy trình được lưu trữ từ khung thực thể.

+0

bạn đã xem xét các câu trả lời cho câu hỏi này? http://stackoverflow.com/questions/15146425/creating-reports-in-asp-net-with-entity-framework – Nathan

Trả lời

3
public void getMyReportData() 
{ 
    using (myEntityDataModel v = new myEntityDataModel()) 
    { 

     var reportQuery = (from r in v.myTable 
           select new 
           { 
            l.ID, 
            l.LeaveApplicationDate, 
            l.EmployeeNumber, 
            l.EmployeeName, 
            l.StartDate, 
            l.Col1, 
            l.Col2, 
            ......., 
            ......., 
            l.Address 
           }).ToList(); 

     reportViewer1.LocalReport.DataSources.Clear(); 
     ReportDataSource datasource = new ReportDataSource("nameOfReportDataset", reportQuery); 
     reportViewer1.LocalReport.DataSources.Add(datasource); 

     Stream rpt = loadEmbededReportDefinition("Report1.rdlc"); 
     reportViewer1.LocalReport.LoadReportDefinition(rpt); 
     reportViewer1.RefreshReport(); 

     //Another way of setting the reportViewer report source 

     string exeFolder = Path.GetDirectoryName(Application.ExecutablePath); 
     string reportPath = Path.Combine(exeFolder, @"rdlcReports\Report1.rdlc"); 
     reportViewer1.LocalReport.ReportPath = reportPath; 

     reportParameter p = new ReportParameter("DeptID", deptID.ToString()); 
     reportViewer1.LocalReport.SetParameters(new[] { p }); 

    } 
} 




public static Stream loadEmbededReportDefinition(string reportName) 
    { 
     Assembly _assembly = Assembly.GetExecutingAssembly(); 
     Stream _reportStream = _assembly.GetManifestResourceStream("ProjectNamespace.rdlcReportsFolder." + reportName); 

     return _reportStream; 
    } 

nguồn gốc: Creating Reports in ASP.Net with Entity Framework

Các vấn đề liên quan