In my application I get about 2000 records from database and it takes same time (in this time application is "hanging"). Is possible to execute asynchronous query using openAccess.
Executing an asynchronous query using OpenAccess is not currently supported out of the box and in order to select records in asynchronous way I suggest you the following options:
Use an asynchronous Task – choosing this approach you will have control how the task will be executed and scheduled by the thread pool, you will be able to cancel already started tasks and you can easily specify what are the next steps after the task is complete.
Use the ThreadPool – this approach offers a simpler implementation if you need to run a few independent queries and has slightly better performance. But you will have to define events in order to chain several queries together if your scenario requires so.
For your convenience I prepared a sample application using the Northwind database demonstrating how to extend the IQueryable<T> interface with asynchronous extension methods for the above-mentioned scenarios – you could find it attached.
Please bear in mind that you should not dispose the context before you are sure that all of the asynchronous operations have finished. Otherwise the remaining queries will fail.
Also we listed a feature request for supporting asynchronous queries out of the box. You can vote for it in our new Ideas & Feedback Portal and track its progress. If this appears to be a common request, you may see it included in a future version of the OpenAccess ORM.
I hope this helps.
Kind regards,
Dimitar Tachev
the Telerik team
Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
I know you can use Task.Run or Task.StartFactory but this has thread creation and management overhead; performance will be degraded as the number of threads increases.