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.
public static List<Customer> GetCustomers()
IObjectScope scope = ObjectScopeProvider1.GetNewObjectScope();
List<Customer> result = (from c in scope.Extent<Customer>() select c).ToList();
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)() _
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:
this.DataSource = Class1.GetCustomers();
Me.DataSource = Class1.GetCustomers()