RIA LINQ Async operation

4 posts, 0 answers
  1. Phil
    Phil avatar
    8 posts
    Member since:
    Dec 2010

    Posted 10 Sep 2011 Link to this post

    OK, what I want to do is really simple, and everyone must have to do it, and I have found one way to do it, but surely it can't be this hard. I have a Silverlight application, with RIA data services, and on the client side I simply want to do some rudimentary data access queries within an event procedure.

    Case in point. On an event I want to retrieve a particular known row of an Accounts table, and retrieve the [Name] column. Easy, construct  a LINQ query, accessing the dbContext, but as minimum, it seems you have to call the Load Method, which only initiates the load, then you have to construct a separate event handler for when the LoadOperation is completed, then complete your logic in that separate handler. If you do a lot of these, this is a ridiculously complicated way to get some basic data.

    I read somewhere that calling the .ToList() method forces the LINQ/RIA to retrieve the data before proceeding. I did see it work once, but it appears not to any more. All attempts to simply execute a LINQ query like this appear to return no data, unless you construct the separate LoadOperation.Completed Event Handler, and put further logic there.

    Can someone please show me how to simply retrieve some data via RIA ORM within a single event procedure?
  2. Phil
    Phil avatar
    8 posts
    Member since:
    Dec 2010

    Posted 14 Sep 2011 Link to this post

    Hellooooo . . . . ?
  3. DevCraft banner
  4. Serge
    Admin
    Serge avatar
    375 posts

    Posted 14 Sep 2011 Link to this post

    Hi Phil,

     The problem with Silverlight applications is that you cannot perform time consuming operations in the UI thread. If you were able to force and wait for the service to respond this would hand the Silverlight and its environment (the browser) while the operation is completed. This is why the only allowed way to consume services in a Silverlight application is asynchronously.

    Of course this is something unusual at first, but in the long run it is actually helpful to decouple the view and service layer.

    I hope this is helpful. 

    Regards,
    Serge
    the Telerik team

    Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

  5. Phil
    Phil avatar
    8 posts
    Member since:
    Dec 2010

    Posted 14 Sep 2011 Link to this post

    Ok, thanks for answering. Will try to work with it inside of this.
Back to Top