UWP sqlite-net Async database access

北城以北 提交于 2019-12-25 03:13:13

问题


On my UWP app, I'm using sqlite-net to access the database. According to their GitHub Page I'm using Source Installation. Now I want to migrate to using the Nuget package (To get the latest updates) and they have mentioned getting the PCL package. When I add the PCL package I don't have Async operations available like it was on Source Installation. Please let me know how to proceed on this matter.

When it comes to UWP and I want to use sqlite-net I see soo many nugets in VS 2015 Nuget Package Manager. Please help me which one to choose. (Selected package should not be deprecated in the near future and should be developed actively by the vendor, providing continues updates)


回答1:


Based on your requirements of active development and support, have a look at EntityFramework Core with their SQLite Provider: https://docs.microsoft.com/en-us/ef/core/get-started/uwp/getting-started

This, however, limits the target version of platform to: Windows 10 Fall Creators Update (10.0; build 16299.0)

The package you have highlighted is a wrapper around the SQLite C library developed by the SQLite authors. There is no guarantee that the wrapper lib will always be under active development, but the SQLite C library should be.




回答2:


You need to install both SQLite.Net.Async-PCL and SQLite.Net-PCL to use async operations.

SQLiteConnectionString connString = new SQLiteConnectionString(file.Path, true);
var asyncConnction = new SQLiteAsyncConnection(
    () => {
        return new SQLiteConnectionWithLock(new SQLitePlatformWinRT(), connString);
    }
);

Note that the SQLite.Net-PCL package is different from the one you installed. I'm not sure if the async package is compatible with that one.



来源:https://stackoverflow.com/questions/56361654/uwp-sqlite-net-async-database-access

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!