有谁知道如何在.NET标准库中设置sqlite? SQLite.Net-PCL似乎不兼容,或者至少这是nuget告诉我的。
答案 0 :(得分:3)
是的,这是SQLite包装器的.NET标准实现:
https://github.com/MelbourneDeveloper/SQLite.Net.Standard.git
安装包SQLite.Net.Standard
这很简单,只有一个DLL可以在所有平台上运行。它也针对PCL。
答案 1 :(得分:0)
这是完整的示例。纯 .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
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;
}
}
}
}