Calling an async call inside executor

Skip to first unread message

Jordi Cabré

Jan 12, 2017, 10:08:33 AM1/12/17
to re-motion Users
We've built an Linq provider using re-linq.

This implementation is using a webservice call sending translated sentence to the webservice endpoint:

    public IEnumerable<T> ExecuteCollection<T>(QueryModel queryModel)

QueryModelTranslator translator = new QueryModelTranslator();
SemanticModel.LQLQueryModel lqlQueryModel = translator.LqlQueryModel;

SemanticModel.Visitor.LQLQueryModelVisitor lqlQueryModelVisitor = new SemanticModel.Visitor.LQLQueryModelVisitor();

return this.backend.LEST.LqlApiP.Search<T>(lqlQueryModelVisitor.Sentence);

Search() method returns an IEnumerable<T>. Nevertheless LQLAPI provides an async version of this:

    public interface ILqlApi
IEnumerable<T> Search<T>(string LqlSentence);
Task SearchAsync(string LqlSentence);

After having tested this implementation we're looking forward to use this async method instead of sync version.

We've not tested absolutly nothing yet. Nevertheless, are there some approaches to be able to call to our Linq sentence provider asynchronously?

Michael Ketting

Jan 13, 2017, 2:24:30 AM1/13/17
to re-motion Users
Hello Jordi!
I haven't thought much yet about combining async with linq but I think to have true first class support, the async-APIs would have to be baked into the re-linq APIs. Right now, we only pass IEnumerables between the actual query execution and the public APIs.

An alternative approach would be to wrap/extend the QueryableBase with async-APIs and take the QueryProvider exposed by the QueryableBase and generate the statement and pass it via the new async-API to ADO.NET's own async methods.

You could also check out what Microsoft has done in EntityFramework.Core. There they're using System.Interactive.Async and have implemented async extension methods:
I did not analyze the entire implementation, but it could be that they're actually routing an asynchronous result from ADO.NET to the public API, cast it and work with the async operations.

Best regards, Michael
Reply all
Reply to author
0 new messages