[英]praeclarum sqlite-net Table().Where(Expression) gives Member access failed to compile expression exception C#
[英]c# Create new SQLite file using praeclarum/sqlite-net package (SQLite-net PCL)
我一直在为我的项目寻找SQLite的最佳ORM,并且发现了praeclarum / sqlite-net包
这个问题我不知道如果目录中不存在该SQLite文件,我将如何使用它来创建它。 没有与此相关的文档,我想在用户的“我的文档”文件夹中创建文件。 到目前为止,这是我的代码。
private string databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "AttorneySpace\\database.db");
private SQLiteConnection db;
public SQLiteDb()
{
if (!Directory.Exists(databasePath))
{
Directory.CreateDirectory(databasePath);
}
db = new SQLiteConnection(databasePath);
db.CreateTable<Stock>();
db.CreateTable<Valuation>();
}
为此,我得到了例外。
An exception of type 'SQLite.SQLiteException' occurred in SQLite-net.dll but was not handled in user code
Could not open database file: ...AttorneySpace\database.db (CannotOpen)
我设法用System.Data.SQLite.SQLiteConnection
创建了文件,尽管它不是我正在使用的库的一部分。
System.Data.SQLite.SQLiteConnection.CreateFile(databasePath);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.