locked
.Net Client fails to Update Odata Controller RRS feed

  • Question

  • Created an Odata MVC WEb API. Running it Locally IIS Express 7.5 to debug it.

    Created a .Net WPF client app.

    Here is code to load from client:

    private Container _proxy;

    private DataServiceCollection<EF_WO> _wos = new DataServiceCollection<EF_WO>();

    I am able to Get data and can step through the Odata call.

    I am able to Insert and Delete Data and can step through the Odata call

    I Cannot Update, when I change values in a WPF datagrid and call Savechanges . It will not call the Odata UpdateEntityKey override

    Even if I manually update the dataservice collection from the client it will not update. It gives a generic DataserviceRequestError.

    I looked at the Entity and its state is modified...

    The IIS Express Log says a 404 Error?

    Please Help...

    Server :

    Using Entity Framework 5

    Using Oracle 11.2.30.2 Client

    Project is ASP.Net WEB API MVC 4

    Odata

    Client:

    WPF application using a datagrid

    Friday, June 14, 2013 8:07 PM

Answers

  • I was calling savechanges

    needed to call

    container.SaveChanges(SaveChangesOptions.PatchOnUpdate); 

    • Marked as answer by kkalright Monday, June 24, 2013 2:04 PM
    Monday, June 24, 2013 2:04 PM

All replies

  • Forgot.. VS 2012 Update 2
    Friday, June 14, 2013 9:52 PM
  • Hi kkalright,

    I'll try to involve other engineers more familiar with the issue in the thread. It will take some time to get the response. Your patience will be greatly appreciated.

    Thanks for your understanding.

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, June 17, 2013 10:51 AM
    Moderator
  • Thanks...

    I tried doing a PUT request in Fiddler and the update works fine. Must be something with the DataServices Client...

    Monday, June 17, 2013 12:28 PM
  • I was calling savechanges

    needed to call

    container.SaveChanges(SaveChangesOptions.PatchOnUpdate); 

    • Marked as answer by kkalright Monday, June 24, 2013 2:04 PM
    Monday, June 24, 2013 2:04 PM
  •                        

    IQueryable<Wall> wallOneQuery = _OdataProxy.Walls.Where(w => w.WallID == 1);

                           

    varwallOne = awaitGetWallsAsync(wallOneQuery);

                          

    Wallwall1 = wallOne.FirstOrDefault();

                            wall1.LikesCount++;

                           

    //_OdataProxy.AttachTo("Walls", wallOne);


                           

    //_OdataProxy.UsePostTunneling = true;


                            _OdataProxy.UpdateObject(wall1);

                            _OdataProxy.BeginSaveChanges(

    SaveChangesOptions.PatchOnUpdate,

                                obj =>

                                {

                                   

    if(obj.IsCompleted)

                                    {

                                        dispatcher.BeginInvoke(() =>

                                        {

                                           

    this.WallOneLikesCount = wall1.LikesCount;

                                        });

                                    }

                                },

    null);

    The Above code doesn't works for me, fiddler says

    <m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">

      <m:code />

      <m:message xml:lang="en-US">No HTTP resource was found that matches the request URI 'http://localhost:28287/odata/Walls(1)'.</m:message>

      <m:innererror>

        <m:message>No routing convention was found to select an action for the OData path with template '~/entityset/key'.</m:message>

        <m:type></m:type>

        <m:stacktrace></m:stacktrace>

      </m:innererror>

    </m:error>

    The Other methods

    However, when I try to do patch from FIDDLER itself, it works fine and performs PATCH for my DB.

    this has drawn me crazy since 3 days now ....if someone can make this work ....I will , I will ...ummm not forgot to wish him/her Happy Birthday every year : / HELP Please :/


    • Edited by GautamNigam Thursday, March 20, 2014 7:08 AM
    Thursday, March 20, 2014 7:02 AM