mfenniak / rethinkdb-net

A C# / .NET client driver for RethinkDB.
Other
247 stars 37 forks source link

Load Data Async/Await #254

Closed lyquocnam closed 8 years ago

lyquocnam commented 8 years ago

i try this code to load data with async method but not work await conn.RunAsync(Person.Table);

error: IAsyncEnumerator' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'IAsyncEnumerator' could be found (are you missing a using directive or an assembly reference?

conn.RunAsync(Person.Table); not have awaiter ?

this work ok ! conn.Run(Person.Table);

mfenniak commented 8 years ago

RunAsync returns an IAsyncEnumerator (https://github.com/mfenniak/rethinkdb-net/blob/master/rethinkdb-net/Interfaces/IAsyncEnumerator.cs). It's like an IEnumerator, but with an async MoveNext function. So you would then 'await enumerator.MoveNext();' and access .Current.

Here's an example in our test code of reading from the async enumerator: https://github.com/mfenniak/rethinkdb-net/blob/290eeb6da3c25b19d297b7b7671db998139f97b4/rethinkdb-net-test/Integration/MultiTableTests.cs#L82