locked
How to call stored procedure after import SP as function at client side? RRS feed

  • Question

  • At server side, create EDM and ADO.NET Data Service. Then added reference in silverlight project and make async call to get data from database. It is okay to use entityset to get collection of entity. 

    In EDM, using Add-->Import Function to add a stored procedure, and I can see it in generated code file(like NorthwindEntity.designer.cs).

    Then Update reference in silverlight project, but I can find out the function to match the stored procedure!

    For example, when import the function for SP, I named it as mySearch, then I can see the code generated like

    public global::System.Data.Objects.ObjectResult<People> mySearch(....//parameters here //   )...

    But at client side(silverlight project), I can't get see any method like mySearch when using the proxy from the reference.

    How to solve this issue? Sample code to make async call on stored procedure at client side please.
    Monday, January 5, 2009 1:08 AM

Answers

  • The context constructor takes the base URI of the data service and not the URI of the service operation

    context =

    new CategoryRef.CategoryDBEntities(new Uri(HtmlPage.Document.DocumentUri,"/CategoryDS.svc",UriKind.RelativeOrAbsolute));

    string query = string.Format("categoryid?id={0}", categoryID);

     

    context.Execute<Category>(query)

    context.Execute<Category>(query)


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Tuesday, June 16, 2009 4:11 PM
    Moderator

All replies

  • Hi Kent

    The ADO.NET Data Service edm code generator does not create methods for service opertations. You have to call them using the execute methods on the client side api.

    Regards

    Daniel Portella
    http://undocnet.blogspot.com

    Thursday, January 8, 2009 1:04 PM
  • thank you very much. Sample code at client side please.
    Thursday, January 8, 2009 11:49 PM
  • KentZhou said:

    thank you very much. Sample code at client side please.

    Do something like this on the client side from win-client.  Basically, you have to build your uri query manually.

    public TimeLog GetClockStatus(int employeeId)

    {

    string query = string.Format("GetClockStatus?employeeId={0}", employeeId);

    TimeLog tl = this.Execute<TimeLog>(query.ToRelativeUri()).SingleOrDefault();

    return tl;

    }

    • Proposed as answer by WilliamStacey Monday, January 12, 2009 3:30 PM
    Monday, January 12, 2009 3:30 PM
  • Hi,

    I have tried the same procedure as mentioned in the above to access a ADO.Net storedprocedure with parameters in silverlight application. But i am getting error
    Expected an absolute, well formed http URL without a query or fragment.
    Parameter name: serviceRoot
        while executing the statement

    context =

    new CategoryRef.CategoryDBEntities(new Uri(HtmlPage.Document.DocumentUri, "CategoryDS.svc/GetCategory?categoryid=2"));

    Please help me



    • Proposed as answer by infy123 Wednesday, July 22, 2009 7:01 AM
    Monday, June 15, 2009 12:10 PM
  • The context constructor takes the base URI of the data service and not the URI of the service operation

    context =

    new CategoryRef.CategoryDBEntities(new Uri(HtmlPage.Document.DocumentUri,"/CategoryDS.svc",UriKind.RelativeOrAbsolute));

    string query = string.Format("categoryid?id={0}", categoryID);

     

    context.Execute<Category>(query)

    context.Execute<Category>(query)


    Phani Raj Astoria http://blogs.msdn.com/PhaniRaj
    Tuesday, June 16, 2009 4:11 PM
    Moderator