【发布时间】:2014-08-12 08:32:34
【问题描述】:
我正在为我的 PCL 中的通用应用程序项目使用新的 SQLite 可移植类库 (PCL)。
我可以将字符串放入整数,也可以将字符串放入大小有限的字段。将插入所有值而不会出现警告或错误。
此外,我可以创建没有传递数据类型的表,或者我可以将任何内容设置为数据类型。这让我认为所有字段都将是相同的数据类型(可能是一个可以放入任何内容的文本)。这方面似乎会影响性能。我是否配置了其他东西?
例如:
using (var c = new SQLiteConnection(_dbName))
{
using (var statement = c.Prepare(@"CREATE TABLE IF NOT EXISTS Test (
Id INTEGER NOT NULL PRIMARY KEY,
MyString LALALA NOT NULL,
MyInt INTEGER NOT NULL);"))
{
statement.Step();
}
}
using (var statement = c.Prepare(@"INSERT INTO Test (MyString, MyInt)
VALUES(@myString, @myInt);"))
{
statement.Bind("@myString", "hello tablehello tablehello tablehello tablehello tablehello tablehello table");
statement.Bind("@myInt", "9asd");
// Inserts data.
statement.Step();
// Resets the statement, to that it can be used again (with different parameters).
statement.Reset();
statement.ClearBindings();
statement.Bind("@myString", "hello world");
statement.Bind("@myInt", "asdasd");
// Inserts data.
statement.Step();
}
而且一切正常 - 为什么?
另外,是否可以以只读方式打开连接? 在其他 sqlite 库中这是可能的。
再见 马库斯
【问题讨论】:
标签: c# sqlite win-universal-app portable-class-library