This is a migrated thread and some comments may be shown as answers.

unable to call SP ria services

3 Answers 88 Views
Getting Started
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Matt
Top achievements
Rank 1
Matt asked on 20 Feb 2013, 10:03 PM
I am using SL 5 and ria services

following doc

http://www.telerik.com/help/openaccess-orm/developer-guide-crud-sp-support-persistent-type.html

I have followed the instructions to create a persistent type however when I try and populate the listbox no data appears. Can you point out the missing step?

my code

public IEnumerable<StoredProceduresDemo.Category> LoadCategories()
{
   IEnumerable<StoredProceduresDemo.Category> queryResult =
this.ExecuteQuery<StoredProceduresDemo.Category>("LoadCategories", CommandType.StoredProcedure);

   
return queryResult;
}

my xaml:

 

<telerik:RadListBox Grid.Row="2"

                    x:Name="FriendlyNamesListBox"

                    ItemsSource="{Binding Path=LoadCatagories}"/>

thanks
matt

 

3 Answers, 1 is accepted

Sort by
0
Boris Georgiev
Telerik team
answered on 25 Feb 2013, 01:04 PM
Hello Matt,

I have prepared a sample application which demonstrates how to populate list boxes from two different stored procedures. The sample is using SofiaCarRental21 Database

1) For the first list box I used a stored procedure with a new complex type for return type - CarInfo.
Here is the SQL Script for this stored procedure:
USE [SofiaCarRental21]
GO
 
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[TestStoredProc]'))
DROP PROCEDURE [dbo].[TestStoredProc]
GO
 
CREATE PROCEDURE [dbo].[TestStoredProc]
AS
    SET NOCOUNT ON;
    SELECT c.Make, c.Model
    FROM [dbo].[Cars] AS c
    WHERE c.CategoryID = 1
 
GO

2) For the other two list boxes I used a stored procedure returning an existing Persistent Type - Car.
Here is the SQL Script for the second stored procedure:
USE [SofiaCarRental21]
GO
 
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[[TestStoredProcPersistent]]'))
DROP PROCEDURE [dbo].[TestStoredProcPersistent]
GO
 
CREATE PROCEDURE [dbo].[TestStoredProcPersistent]
AS
    SET NOCOUNT ON;
    SELECT *
    FROM [dbo].[Cars] AS c
    WHERE c.CategoryID = 1
 
GO

For both of the Stored Procedures you should extend your Service class how its described in this article:
01.public partial class DomainService1
02.{
03.    public IEnumerable<CarInfo> GetCarMakeModel()
04.    {
05.        var carMakeModel = this.DataContext.TestStoredProc();
06. 
07.        return carMakeModel;
08.    }
09. 
10.    public IEnumerable<Car> GetCarsFromStoredProcedure()
11.    {
12.        var cars = this.DataContext.TestStoredProcPersistent();
13. 
14.        return cars;
15.    }
16.}

After extending your service class with the methods above you can populate the list boxes in the Silverlight application with the results returned by the stored procedures.

We also provide a sample "Sofia Car Rental - WCF RIA Services" in Telerik OpenAccess Samples Kit demonstrating the best practices for using Silverlight and WCF RIA Services. The example shows how to implement WCF RIA Services with Telerik OpenAccess ORM in N-Tier Architecture. You can click on the Open Documentation button for the example to access an end-to-end tutorial for building it.

I hope this helps. Do not hesitate to contact us back if you need any further assistance.

Regards,
Boris Georgiev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
0
mike okon
Top achievements
Rank 1
answered on 06 Mar 2013, 10:05 AM
Hi, Thanks so much for this example.

In my opinion this should be placed in the documentation!!! It would save yous at least a couple thousand requests and promote ORM at the same time. A real MUST SEE for anyone looking to use SPs in ORM.

mike

0
Doroteya
Telerik team
answered on 11 Mar 2013, 08:25 AM
Hello Mike,

Thank your for your feedback.

We will consider your suggestion and will make sure that the described scenario is explained properly in our resources.

In the mean time, if you have questions, do not hesitate to get back to us.


Regards,
Doroteya
the Telerik team
OpenAccess ORM Q1 2013 is out featuring Multi-Diagrams, Persistent Data Stream Support and much more. Check out all of the latest highlights.
Tags
Getting Started
Asked by
Matt
Top achievements
Rank 1
Answers by
Boris Georgiev
Telerik team
mike okon
Top achievements
Rank 1
Doroteya
Telerik team
Share this question
or