Search code examples
.netlinq-to-sql.net-4.5async-await

Using Linq to Sql asynchronously with new async/await


What are the best practices to use L2S with new C# 5 async/await keywords comparing to this approach? Couldn't find any on the web.


Solution

  • EF 5 does not have async/await support, but the open source version is actively looking into possibilities here. EDIT: the Async support in EF is documented at http://msdn.microsoft.com/en-us/data/jj819165.aspx. It doesn't stream the results in as they are hydrated (as you would find with RX) but it does make the database calls asynchronous.

    As for LINQ to SQL, outside of wrapping your request in a Task.Factory.Start operation, I wouldn't hold my breath hoping that task based async (required for async/await) will be implemented by Microsoft for Linq to SQL.

    You could use the IQToolkit and extend it adding your own async support if absolutely necessary. Also, Mono has implemented LINQ to SQL which you might be able to extend with async support.