Skip to main content Skip to footer

ActiveReports:Binding Section Reports to Entity Framework

Microsoft's Entity Framework since its inception has become developer's favorite for mapping a R**e**lational Database to a C**o**nceptual Model. Its strength lies in the way it allows developers to modify the C**onceptual Model as per their business logic and still be connected to the Relational Database. In simpler terms Microsoft Entity Framework creates a set of classes from the database schema and allows developers to work on these objects without worrying about the relational object model that works behind the scenes. Developers who would like to leverage the Entity Framework's capabilities by using Conceptual Model as a datasource for a Section report should not doubt ActiveReport's capabilities since its reporting engine is well equipped to handle this. Since the Entity Framework creates a conceptual class objects from the database, we can use these class objects as a data source for the report and hence bind the conceptual model created by the Entity Framework to the report. Steps to set a Model as a data source for the report**

  1. Create classes for the database model using the Entity Framework.If you do not know how to create a database model then take a look at this link
  2. Instantiate the database model class which was created in Step 1.
  3. Create a strongly typed list of the Entity that is part of the model class and set it as a data source for the report

protected void Page_Load(object sender, EventArgs e)  
{  
  SampleDataBaseEntities _db = new SampleDataBaseEntities();  
  SampleReport _rpt = new SampleReport();  

  \_rpt.DataSource = \_db.Student.ToList(); ;  

  WebViewer1.Report = _rpt;  
}  

MESCIUS inc.

comments powered by Disqus