【发布时间】:2014-10-17 17:31:27
【问题描述】:
在this blog post 中,给出了一些在 Windows 应用商店应用程序中开始使用 SQLite 的先决条件代码,用于添加到 App.xaml.cs 的 OnLaunched 方法中:
// Get a reference to the SQLite database
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "customers.sqlite");
我的问题是:我可以使用任意值来替换“customers.sqlite”部分,还是必须与我的代码中的其他内容相匹配,例如我的表定义类的名称(在我的情况下为“PhotraxCoreData .cs”,根据格林先生的建议,我在新创建的“模型”文件夹下面添加了)?
我的理解是,一旦我定义了这些类(我做了),以及 App.xaml.cs 中的上述代码,以及那里的代码(适用于我的 SQLite 类):
using (var db = new SQLite.SQLiteConnection(this.DBPath))
{
// Create the tables if they don't exist
db.CreateTable<PhotraxBaseData>();
db.CreateTable<PhotraxNames>();
db.CreateTable<PhotraxQueries>();
}
...将创建基于我指定的那些类的 SQLite 表,并具有名称“customers.sqlite”(前提是我不更改它)。
那么,我可以使用:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "platypus.sqlite");
...或者必须是这样的:
this.DBPath = Path.Combine(
Windows.Storage.ApplicationData.Current.LocalFolder.Path, "PhotraxCoreData.sqlite");
【问题讨论】:
-
根据罗伯特格林文章中引用的视频,它是一个任意值——它可以是任何值。
标签: sqlite windows-store-apps app.xaml