如何在 .NET Standard 库中使用 Sqlite?

How can I use Sqlite in a .NET Standard library?

有谁知道如何在 .NET Standard 库中设置 sqlite? SQLite.Net-PCL 似乎不兼容,或者至少 nuget 是这么告诉我的。

是的,这是 SQLite 包装器的 .NET 标准实现:

https://github.com/MelbourneDeveloper/SQLite.Net.Standard.git

安装包 SQLite.Net.Standard

非常简单,只有一个DLL,适用于所有平台。它还针对 PCL.

这是完整的示例。纯 .Net 标准

Nuget 包 => sqlite-net-pcl

https://www.nuget.org/packages/sqlite-net-pcl/1.7.335?_src=template

Nuget 包 => System.Data.SQLite https://www.nuget.org/packages/System.Data.SQLite/1.0.114?_src=template

或来自微软的始终更新的 sqlite

https://www.nuget.org/packages/Microsoft.Data.Sqlite

using DB.Extensions;
using DB.Modellers;
using SQLite;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace DB
{
    public class DatabaseAdapterStandard
    {
        
        public string SqlFilePath { get; }
        public DatabaseAdapterStandard(string sqlFilePath)
        {
            this.SqlFilePath = sqlFilePath;
          
        }
       
      
        public IEnumerable<books> GetBooks()
        {
            using (var session = new SQLiteConnection(SqlFilePath))
            {
                var books = session.Table<books>().ToList();
                return books;
            }
        }
        public IEnumerable<chapters> GetChapters(books books)
        {
            using (var session = new SQLiteConnection(SqlFilePath))
            {
                var items = session.Table<chapters>().Where(p=>p.reference_human == books.human).ToList();
                return items;
            }
        }
        public IEnumerable<verses> GetVerses()
        {
            using (var session = new SQLiteConnection(SqlFilePath))
            {
                var items = session.Table<verses>().ToList();
                return items;
            }
        }
    }
}