locked
Problem with ADO.NET DATA Service (Astoria) RRS feed

  • Question

  • Hi,

    I have a problem for consuming the ADO.NET DATA Service.

    I have a application Silverlight with ASTORIA and Entity Framework.

    I generate the class with DataSvcUtil.exe that i added in my Silverlight Project.

                BankTestEntities ctx = new BankTestEntities(new Uri("http://localhost:8888/WebSite1/BankTestDataServices.svc/"));

    var qry = from p in ctx.CREDIT
    select p;

    GridCredit.DataContext = qry;

    In ADO.NET DATA Service I give the necessary autorisations for to consume my data :

    Code :
            config.SetEntitySetAccessRule("*", EntitySetRights.All);

    When i run my application, i don't have a data in my DataGrid although i have some data in my database. When i debug  and i look the content of the results view (Right click to qry), i have this message :


    base {System.SystemException} = {System.NotSupportedException: the method specified is not supported.

    to System.Data.Services.Client.DataServiceQuery`1.System.Collections.Generic.IEnumerable<TElement>.GetEnumerator()

    to System.Linq.SystemCore_EnumerableDebugView`1.get_Items()}

     Thank you for your help.

     PS : Excuse for my bad English.

     

     

    Thursday, July 3, 2008 4:52 AM

Answers

  • Hi ,

     Data access in SIlverlight is asynchronous , the GetEnumerator Method is synchronous and you hence get the notSupportedException. you should use the async methods to achieve this in Silverlight ..

    Change your code to be this ..

    BankTestEntities ctx = new BankTestEntities(new Uri("http://localhost:8888/WebSite1/BankTestDataServices.svc/"));

                var qry = from p in ctx.CREDIT
                          select p;

    AsyncCallback ac = iasyncResult =>{

    IEnumerable<CREDIT> results =  (DataServiceQuery<CREDIT>qry).EndExecute(iasyncResult)            GridCredit.DataContext = results ;
    }

    (DataServiceQuery<CREDIT>qry).BeginExecute(ac,null);

     

    Also , please post queries related to astoria on the astoria forums at :http://forums.microsoft.com/Forums/ShowForum.aspx?ForumID=1430&SiteID=1

    Thursday, July 3, 2008 7:49 PM

All replies

  •  UP,

    You don't have any idea ?

    Thursday, July 3, 2008 8:58 AM
  • Hi ,

     Data access in SIlverlight is asynchronous , the GetEnumerator Method is synchronous and you hence get the notSupportedException. you should use the async methods to achieve this in Silverlight ..

    Change your code to be this ..

    BankTestEntities ctx = new BankTestEntities(new Uri("http://localhost:8888/WebSite1/BankTestDataServices.svc/"));

                var qry = from p in ctx.CREDIT
                          select p;

    AsyncCallback ac = iasyncResult =>{

    IEnumerable<CREDIT> results =  (DataServiceQuery<CREDIT>qry).EndExecute(iasyncResult)            GridCredit.DataContext = results ;
    }

    (DataServiceQuery<CREDIT>qry).BeginExecute(ac,null);

     

    Also , please post queries related to astoria on the astoria forums at :http://forums.microsoft.com/Forums/ShowForum.aspx?ForumID=1430&SiteID=1

    Thursday, July 3, 2008 7:49 PM
  •  Hi,

     

    This article is very nice. It hlped a lot.

     

    Thanks

    Tuesday, October 21, 2008 11:56 AM
  • Hi,

     I have the same problem, and i used the async methods.The error seem to appear when i create the proxy(ctx in this case).

    Any advice?

     

    Thank you in advance.

     

    Adina

    Wednesday, October 22, 2008 6:04 AM