Dear ladies and sirs.
I wonder if there is an in-memory database implementation, where the same in-memory database instance can be used across multiple AppDomains.
The motivation. Like many folks out there, we have integration tests for our client-server application. There are several test modes, from the most heavy one - the real life scenario, where the client, server and database are all located on different machines to the most lightweight one, where both the client and server are simply two AppDomains in the same process and the database is an sqlite file on the same machine.
Naturally, the lightweight scenario is the fastest and developers routinely use it, while the heavy one is run on our CI server on each build.
My goal is to further speed up the lightweight scenario by using an in-memory database.
The problem. OK, so sqlite has an in-memory database option, but such a database:
- is disposed of after a connection to it is closed.
- cannot have two open connections, new connections open another database instance.
Unfortunately, I need two - one for the test staging code, which runs in the client side AppDomain and the other - for the server side DAL.
I realize the rationale behind the way sqlite in-memory database works. I am also aware of the difficulties of having in-memory database shared between two AppDomains. How can one share a memory buffer between two AppDomains without reverting to memory mapped files (and I do not want to deal with any File System API)?
The only efficient solution that I see is having two AppDomains share an unmanaged memory buffer, where the handle to the buffer would be passed from one AppDomain to another. But are there any in-memory database implementations that support this setup?
(An inefficient solution would be to pass the whole database from one AppDomain to another and then back again).
I may be completely wrong with my analysis and there may be simple solutions which I miss. Anyway, I would like to know if anyone has encountered the same problem and how have they solved it.
P.S.
I would really like to avoid any kind of File API, like memory mapped files.