LiteDB in .net MAUI: a proper way to organize LiteDatabase's life cycle

193 Views Asked by At

I use sqlite in my .net maui app, but now I decided to migrate it to LiteDb since I feel like no-sql type of db better serves my app needs. In my app I used singelton wrapper around SQLiteAsyncConnection. With LiteDb I noticed in their doc LiteDatabase as a core object handling connection to the db is intstantiated and disposed immediately

using(var db = new LiteDatabase(@"C:\Temp\MyData.db"))
{
   ...
}

also found more examples of handling it the same way. Those examples are more like demo projects though, was not able to find a real project.

I wonder won't it make too much overhead of handling connection this way, instigating and disposing it on demand, rather than having a singleton wrapping the LiteDatabase? My app constantly reads data from the local db, with pretty much every click, sometimes writes.

0

There are 0 best solutions below