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

WCF Service with Stored Procedures

1 Answer 104 Views
Web Services
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Patrick
Top achievements
Rank 1
Patrick asked on 25 Sep 2013, 07:00 PM
Hi there,

we have created a WCF webservice using OpenAccess from Telerik and it works all fine with entities and views.
We are now trying to use some stored procedures but we are not able to access them like we do with the tables and views.

What we've done sofar was creating a partial class to extend the EntitiesModelService with a method to call the stored procedure.
We've already created a Domain Method for the stored procedure in the model.

public partial class EntitiesModelService
    {
        [WebGet]
        public IEnumerable<Store> FncGetNearbyPlaces(float? lat, float? lng, float? distance)
        {
            return (new EntitiesModel()).FncGetNearbyPlaces(lat, lng, distance);
        }
    }

and added this line in the EntitiesModelService

public static void InitializeService(DataServiceConfiguration config)
   {
            ...
   config.SetServiceOperationAccessRule("FncGetNearbyPlaces", ServiceOperationRights.All);
  
   }


we have followed the indications on this post: http://www.telerik.com/community/forums/orm/getting-started/using-stored-procedures-in-entity-model-with-a-service.aspx

Thanks in advance for your help!!!

Antonio.

1 Answer, 1 is accepted

Sort by
0
Viktor Zhivkov
Telerik team
answered on 26 Sep 2013, 08:58 AM
Hello Patrick,

I believe that you have used the right code and configuration for your custom Data Service method.
How did you try to call your method?
Calling a method with float parameters can be a bit tricky but can be done using the following request pattern:
// provide all arguments for all parameters
http://[host]:[port]/EntitiesModelService.svc/FncGetNearbyPlaces?lat=1.0f&lng=75.0f&distance=10f
 
// provide arguments for some parameters
http://[host]:[port]/EntitiesModelService.svc/FncGetNearbyPlaces?lat=40.0f&distance=100.5f

The most important thing there is to use the right representation for the parameter type - in your case you have to append "f" suffix to the float value.

If  you had trouble getting a Service Reference proxy in a .Net client application with code to call the custom operation you can read this article. There you can find explanation why no code is generated for service operations and what to do in order to call one.

If you need any further assistance do not hesitate to contact us with your questions.

Regards,
Viktor Zhivkov
Telerik
OpenAccess ORM Q3 2013 Beta is available for immediate download in your account. Get it now and play with the latest bits. See what's new >>
Tags
Web Services
Asked by
Patrick
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Share this question
or