unable to call SP ria services

4 posts, 0 answers
  1. Matt
    Matt avatar
    2 posts
    Member since:
    Feb 2013

    Posted 20 Feb 2013 Link to this post

    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

     

  2. Boris Georgiev
    Admin
    Boris Georgiev avatar
    190 posts

    Posted 25 Feb 2013 Link to this post

    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.
  3. DevCraft banner
  4. mike okon
    mike okon avatar
    40 posts
    Member since:
    Dec 2009

    Posted 06 Mar 2013 Link to this post

    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

  5. Doroteya
    Admin
    Doroteya avatar
    502 posts

    Posted 11 Mar 2013 Link to this post

    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.
Back to Top