views:

23

answers:

1

The following code throws an exception which I have no idea what goes wrong , can anyone shed some light on this one please?

RestAPIDataContext ctx = GetContext();            
var songsQuery = (from item in ctx.Songs
                                  where item.Artist.Title == "George Michael"
                                  select item) as DataServiceQuery<SongsItem>;
                    songsQuery.BeginExecute(
                        (IAsyncResult asyncResult) => Dispatcher.BeginInvoke(() =>
                                                                                 {
                                                                                     songsList.ItemsSource = songsQuery.EndExecute(asyncResult);
                                                                                 }), songsQuery
                        );
private static RestAPIDataContext GetContext()
        {
            RestAPIDataContext ctx =
              new RestAPIDataContext(
              new Uri("http://win-oirj50igics/restapi/_vti_bin/ListData.svc"));
            return ctx;
        }

System.Data.Services.Client.DataServiceQueryException: An error occurred while processing this request. ---> System.InvalidOperationException: An error occurred while saving changes. See the inner exception for details. ---> System.Data.Services.Client.DataServiceClientException: Request version '1.0' is too low for the response. The lowest supported version is '2.0'. --- End of inner exception stack trace --- at System.Data.Services.Client.BaseAsyncResult.EndExecute[T](Object source, String method, IAsyncResult asyncResult) at System.Data.Services.Client.QueryAsyncResult.EndExecute[TElement](Object source, IAsyncResult asyncResult) --- End of inner exception stack trace --- at System.Data.Services.Client.QueryAsyncResult.EndExecute[TElement](Object source, IAsyncResult asyncResult) at System.Data.Services.Client.DataServiceQuery`1.EndExecute(IAsyncResult asyncResult) at SLRest.MainPage.<>c_DisplayClass3.<>c_DisplayClass5.b__1()

+1  A: 

from the call stack it looks like you are using a ADO.Net data service framework. you can either try to update it using this link or change the target framework of your caller application to 4.0.

Check this link for details

Vinay B R
Thanks mate , your solution work.But mine is not console app, it is SilverLight app.So I change my SilverLight app version from 3.0 to 4.0 and it works fine now.
Ybbest

related questions