locked
WCf Data Service Operations RRS feed

  • Question

  • Hi

    I am working on WCF data Service in WA . To display data from SQL Azure i am using entity framwork with WCF Data Service and working fine.

    Similarly i want to insert data thro' WCF Data Service using Entity model , my service url is

    http://localhost:52168/AdventureService.svc/SelectEmp

    for this i want to pass multiple parameters(like Fname , Lname etc... ) to a method , named insertemployee, written in .svc file.

    I dont know how to pass more than one parameter from .aspx.cs file to .svc file( Data Service file) 

    Friday, October 8, 2010 8:22 AM

Answers

  • If you are consuming service from ASP.NET application, then leveraging DataService Client library would be much convenient than working with REST based URL access.

    DataServiceContext facilitates all CRUD operations by generating REST calls for you which will inturn act on the Entity modal and then on

    the undelying datasouce/database.  For updating, you could update the object and invoke context.UpdateObject(<updatedObjec>) method. You can find an example here, If you like to do the same with REST based , you would need to do POST operation and operation needs to be defined in the service with WebInvoke attribute.

    HTH,


    Please mark it as answer by clicking on "Propose As Answer", if it helps
    Friday, October 8, 2010 1:00 PM

All replies

  • This is actually a pretty simple WCF issue. Simply make sure your service method has the proper parameters declared in both the interface declaration and its accompanying definition. The parameters will be delared just as you would any other class definition. If you are passing an object, I recommend defining that class as a data contract and make sure all its members are serializable.

    Friday, October 8, 2010 11:03 AM
  • i am not using 'WCF service' , i am using 'WCF Data Service' in which i am not using any operation contract or data contract.

    Is it  the same solution for 'WCF service' and 'WCF Data Service' ?

    Friday, October 8, 2010 12:44 PM
  • If you are consuming service from ASP.NET application, then leveraging DataService Client library would be much convenient than working with REST based URL access.

    DataServiceContext facilitates all CRUD operations by generating REST calls for you which will inturn act on the Entity modal and then on

    the undelying datasouce/database.  For updating, you could update the object and invoke context.UpdateObject(<updatedObjec>) method. You can find an example here, If you like to do the same with REST based , you would need to do POST operation and operation needs to be defined in the service with WebInvoke attribute.

    HTH,


    Please mark it as answer by clicking on "Propose As Answer", if it helps
    Friday, October 8, 2010 1:00 PM