This is a migrated thread and some comments may be shown as answers.

RIA LINQ Async operation

3 Answers 56 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Phil
Top achievements
Rank 1
Phil asked on 10 Sep 2011, 01:15 PM
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?

3 Answers, 1 is accepted

Sort by
0
Phil
Top achievements
Rank 1
answered on 14 Sep 2011, 07:57 AM
Hellooooo . . . . ?
0
Serge
Telerik team
answered on 14 Sep 2011, 10:40 AM
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 >>

0
Phil
Top achievements
Rank 1
answered on 14 Sep 2011, 11:10 AM
Ok, thanks for answering. Will try to work with it inside of this.
Tags
LINQ (LINQ specific questions)
Asked by
Phil
Top achievements
Rank 1
Answers by
Phil
Top achievements
Rank 1
Serge
Telerik team
Share this question
or