jeudi 23 avril 2015

Connection string using SQLiteAsyncConnection?

How to write a connection string using the SQLiteAsyncConnection? I was using sqlite-net, since it didn't support relationships I was forced to install the SQLite.Net.Async.Extensions NuGet package, which works on top of the sqlite-net package. There are a lot of outdated information on the actual implementation of the SQLiteAsyncConnection class. Most of the sites say:

string dbPath = Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, "db.sqlite");

var db = new SQLiteAsyncConnection(dbPath)

But this doesn't work, I have seen somewhere that it should be used this way:

var connectionFactory = new Func<SQLiteConnectionWithLock>(() => new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), new SQLiteConnectionString(databasePath, storeDateTimeAsTicks: false)));
        var asyncConnection = new SQLiteAsyncConnection(connectionFactory);

This code produces a lot of red squiggly's, and I am not sure how to resolve it, since it doesn't provide an option to resolve it on the context menu. And another code that implements the connection using SQLiteAsyncConnection class is:

connection = new SQLiteConnection(new SQLitePlatformWinRT(), Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolder.Path, DATABASE_NAME));

I have no idea whats going on.Just stuck on this now. Appreciate help with detailed steps.

Aucun commentaire:

Enregistrer un commentaire