Telerik OpenAccess Classic

Telerik OpenAccess ORM Send comments on this topic.
How to: Integrate Telerik OpenAccess ORM with Telerik Reporting
Programmer's Guide > OpenAccess ORM Classic (Old API) > OpenAccess Tasks > Integration and Installation > How to: Integrate Telerik OpenAccess ORM with Telerik Reporting

Glossary Item Box

This documentation article is a legacy resource describing the functionality of the deprecated OpenAccess Classic only. The contemporary documentation of Telerik OpenAccess ORM is available here.

Requirements:

The Northwind persistent model will be needed for completing this tutorial. You can find the data model here.

 

Open the solution containing the data model.Add a new project by clicking File->Add->New Project inside Visual Studio. Select the class library (or windows application) project type. Now that you have your class library you need to add reference to the class library which contains the persistent classes for the northwind database. click on your reference folder of the project  and select “Add Reference…”.

When the pop up for selecting reference appears click on the Projects tab and select the project that contains your persistent classes. Click OK to add the reference.

Now that you have your references set you need to enable your project to use Telerik OpenAccess Orm. 

Select the Enable project to use ORM… option from the main OpenAccess menu.

You need ’persistent classes’ and ‘data access code’ options unchecked so that only the enabling part of the procedure executes - it will only enable your project to use Orm which is exactly what you need.

Next step is to add your report designer form. Click on the project and from the context menu select the ‘add new item’ command.

Inside the dialog select ‘Telerik Reporting’ item.

Click on your report item and press F4 to go to the properties. Now you have to select the data source for the report from the properties page.

Click Add Project Data Source.

Select business Object and press next.

Expand your reference class and find the Class you need in your report.

For the purposes of the following example the Customer class has been chosen to be shown in the report.


Now you can add some items to your report form (textboxes, picture fields etc). Those Items need to be bound to a property from the class that you selected. This is done by simply changing their value property.

You can open the expression editor for the value property from the properties page of the selected reporting item.

Select the class property you wish to bind to your reporting item.
The only thing left for you is to write the code that will return the desired information. For the purpose of this example a simple LINQ query that returns all the available customers has been used.

C# Copy Code
public static List<Customer> GetCustomers()
       {
           IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();
           List<Customer> result = (from c
in scope.Extent<Customer>() select c).ToList();
           
return result;
       }  
VB.NET Copy Code
Public Shared Function GetCustomers() As List(Of Customer)
   Dim scope As IObjectScope = ObjectScopeProvider1.GetNewObjectScope()
   Dim result As List(Of Customer) = (From c In scope.Extent(Of Customer)() _
                                      Select c).ToList()
   Return result
End Function

You can add function inside a class in the project that contains the report designer form.
Executing this function will result in all Customers objects being fetched from the database. Now you need to actually bind this code to the report.You can do so in the report designer code behind.

You assign the results returned by the OpenAccess query to the report DataSource property:

C# Copy Code
this.DataSource = Class1.GetCustomers();  
VB.NET Copy Code
Me.DataSource = Class1.GetCustomers()