Async support in ServiceStack and OrmLite
Asked Answered
G

3

6

Currently there exists an async branch of ServiceStack which will make it possible to create async services. But to get all benefits of async, all IO bound operations should be async and therefore all database requests should also be async. I am currently using OrmLite with Postgresql and I would therefore like to know if OrmLite supports async queries/operations? If not, what other .Net Micro-Orms supports async operations?

Gilford answered 9/9, 2012 at 12:20 Comment(0)
B
4

OrmLite has 1st class Async support for all its RDBMS Providers which support async ADO.NET provider implementations (inc. PostgreSQL/Npgsql), otherwise falls back "pseudo async" support over its sync ADO.NET provider APIs which allows using Async APIs in RDBMS providers that don't support it whilst able to benefit from async implementations when running against RDBMS providers that do.

Bethought answered 9/9, 2012 at 17:48 Comment(1)
too shame for not being async out of the boxPreshrunk
S
2

I've recently begun work on AsyncPoco, a fully asynchronous fork of the popular PetaPoco micro-ORM. It still needs some testing and some proper documentation/examples, and as of yet does not support PostgreSQL. UPDATE: AsyncPoco now has some basic documentation and samples, and PostgreSQL is now supported!

At any rate, you asked about other .NET micro-ORMs that support async operations, so I thought I thought I'd mention it as one to keep any eye on.

Stonedeaf answered 21/12, 2013 at 18:36 Comment(0)
U
-1

Sorry if I misunderstood the question

but why can you not wrap the calls using the Task Parallel Library TPL or equivalent?

This is what I do and I am quite happy with results. At the end of the day you are only querying for data...

Thanks

Underlay answered 24/11, 2012 at 12:57 Comment(2)
You could, but that would entail putting each DB query as a blocking task on some background thread (by TPL defaults, that would be a ThreadPool thread). If the ThreadPool has at most 4 threads (one for each CPU core), then you can have at most 4 outstanding parallel DB queries. This might, in some cases, still be an advantage over doing everything sequentially on a single thread, but often you already have multiple concurrent threads going on anyway. With proper async, you could have many, many concurrently running DB queries outstanding.Sorrells
This will enable you to run those operations concurrently, the OP asked about running them asynchronously. Very different. Async on the server is all about consuming fewer threads, not more.Stonedeaf

© 2022 - 2024 — McMap. All rights reserved.