Repository navigation
Async ADO.NET #4958
|
Hi fellow developers, Regards |
Replies: 3 comments 1 reply
|
We are using async with EFCore and it's working okay. Async rules make it a bit tricky because you have to either make the ef core operation thread safe (aware) or wait after each property with an async rule attached to ensure not concurrent access. I'd love to use cancellation tokens but I haven't had the time yet to come up with a proper solution to distinguish between an operation which should be cancelled when the request is cancelled/closed or must run until it's finished even though the caller doesn't get the result. |
|
Keep the whole call chain asynchronous: the caller awaits Here is a complete console example with CSLA 10.2.0 and Npgsql 10.0.3. It returns a populated read-only CSLA list, preserves database nulls, and opens a separate connection per operation from a shared data source. Its runnable PostgreSQL checks cover delayed query completion, zero/one/multiple rows, provider errors and a successful later fetch. They also exercise the DAL directly, since the local console portal's internal scheduling alone does not establish asynchronous provider IO. For the optional cancellation part, the DAL accepts a token and passes it to those provider operations. The example verifies cancellation of an already-running PostgreSQL query and a successful subsequent fetch. It deliberately leaves that token at the DAL boundary: it does not propagate tokens through a remote data portal or choose which business operations must finish after a caller disconnects. This uses native |
|
Thanks everyone. I am going to look at @tevinch example over the weekend. |
Keep the whole call chain asynchronous: the caller awaits
IDataPortal<T>.FetchAsync, the attributed[Fetch]method returnsasync Taskand awaits the DAL, and the DAL awaitsOpenConnectionAsync,ExecuteReaderAsyncand eachReadAsync.Here is a complete console example with CSLA 10.2.0 and Npgsql 10.0.3. It returns a populated read-only CSLA list, preserves database nulls, and opens a separate connection per operation from a shared data source. Its runnable PostgreSQL checks cover delayed query completion, zero/one/multiple rows, provider errors and a successful later fetch. They also exercise the DAL directly, since the local console portal's internal scheduling alone does not establish as…