ASP.NET – Embedded SSRS Report with Entity Framework Data Source

ASP.NET – Embedded SSRS Report with Entity Framework Data Source

1. Add the "ReportViewerForMvc" Library on the Project First …
 
2. Prepare the Entity Framework as a Data Access Layer to Microsoft SQL Server …
 
3. Prepare the Code as a Business Object Layer with a Function which would return the Data Collection in IEnumerable<XXXX> Data Type from Entity Framework Data Access Layer.
 
4. Create a Report Wizard Item from the Web Application Project by using Visual Studio.
 
5. Assign the Prepared Function Name and the Class Namespace as an Available Datasets and Data Source from the Report Wizard Configuration.
 
6. Design & Prepare the Report Content by using the Data Model under the Available Datasets …
 
7. Add the Following Code to Embed the Prepared Report on the ASP.NET Web Page.

 
   this.NationAwardReport.ProcessingMode = Microsoft.Reporting.WebForms.ProcessingMode.Local;
 
   this.NationAwardReport.LocalReport.ReportPath = Server.MapPath( "" ) + @"\Report\NationAwardReport.rdlc";
 
 
   SoccerService obj = new SoccerService();
 
 
   // NationAwardReport is the ASP.NET – SSRS Report Holder Control …
 
   // SoccerDataSet is the named DataSet during Report Wizard Configuration …
 
   // obj.getNationAward() is the prepared function under Business Object Layer which is also assigned on the Report Setting …
 
 
   ReportDataSource datasource = new ReportDataSource( "SoccerDataSet", obj.getNationAward() );
 
   this.NationAwardReport.LocalReport.DataSources.Clear();
 
   this.NationAwardReport.LocalReport.DataSources.Add( datasource );
 
 
   <%@ Register
            Assembly="Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
            Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>
 
   <asp:ScriptManager ID="ScriptManager1" runat="server">
 
      <Scripts>
         <asp:ScriptReference Assembly="ReportViewerForMvc" Name="ReportViewerForMvc.Scripts.PostMessage.js" />
      </Scripts>
 
   </asp:ScriptManager>
 
   <rsweb:ReportViewer ID="NationAwardReport" runat="server"></rsweb:ReportViewer>
 
 
   <system.web>
 
      … …
 
      <httpModules>
 
         … …
 
         <add path="Reserved.ReportViewerWebControl.axd"
            verb="*"
            type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms,
                       Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91"
            validate="false" />
 
      </httpModules>
 
   </system.web>
 
   <system.webServer>
 
      <handlers>
 
         … …
 
         <add name="ReportViewerWebControlHandler"
            preCondition="integratedMode" verb="*" path="Reserved.ReportViewerWebControl.axd"
            type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms,
                       Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
 
      </handlers>
 
      … …
 
   </system.webServer>