Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use SQLiteAsyncConnection from the async PCL version of SQLite?

I'm using a PCL version of Sqlite.net from https://github.com/oysteinkrog/SQLite.Net-PCL

However, I'm unable to get the DB connection setup. The SQliteAsyncConnection does unlike the original version not take a string (path to the DB), but a [Func< SQLiteConnectionWithLock>.]2

How can this be used? In general: how to use this library? I have a core PCL lib which does all the business logic from my iOS, Android and WP8 projects. My understanding was that I can drop the the Sqlite-Net Async PCL into my PCL lib. But it seems like I have to provide some platform specific stuff to get it to work.

like image 993
Krumelur Avatar asked Dec 10 '13 13:12

Krumelur


1 Answers

You just need to create a function that returns a SQLiteConnectionWithLock and pass that to the SQLiteAsyncConnection constructor.

string databasePath = "path";
var connectionFactory = new Func<SQLiteConnectionWithLock>(()=>new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(databasePath, storeDateTimeAsTicks: false)));
var asyncConnection = new SQLiteAsyncConnection(connectionFactory);
like image 124
Johnbot Avatar answered Oct 04 '22 08:10

Johnbot