【发布时间】:2009-08-26 13:24:35
【问题描述】:
我以为这在其他地方有报道,但我现在看不到。无论如何,一个简单的 v3 查询有问题。使用 SQLite ADO.NET 提供程序 1.0.65.0。我的表结构如下:
CREATE TABLE "SamplerData" ("RowId" INT PRIMARY KEY NOT NULL ,"SampName" VARCHAR(128),"SampPurpose" VARCHAR(2048),"ActiveState" INTEGER NOT NULL DEFAULT 1 )
我的 Structs1.cs 文件中有这个:
Columns.Add(new DatabaseColumn("RowId", this)
{
IsPrimaryKey = true,
DataType = DbType.Int32,
IsNullable = false,
AutoIncrement = false,
IsForeignKey = false
});
Columns.Add(new DatabaseColumn("SampName", this)
{
IsPrimaryKey = false,
DataType = DbType.AnsiString,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false
});
Columns.Add(new DatabaseColumn("SampPurpose", this)
{
IsPrimaryKey = false,
DataType = DbType.AnsiString,
IsNullable = true,
AutoIncrement = false,
IsForeignKey = false
});
Columns.Add(new DatabaseColumn("ActiveState", this)
{
IsPrimaryKey = false,
DataType = DbType.Int32,
IsNullable = false,
AutoIncrement = false,
IsForeignKey = false
});
我在 WPF 代码隐藏中有一个查询,如下所示:
SqlQuery sqlsql = new Select()
.From( "SamplerData" )
.Where( "ActiveState" )
.IsEqualTo( 1 );
List<SamplerDatum> sampAll = sqlsql .ExecuteTypedList<SamplerDatum>();
设置断点以显示 sqlsql 的值显示如下:
{SELECT * FROM `SamplerData` WHERE ActiveState = @0}
然后代码抛出:
{“'System.Int64'类型的对象无法转换为'System.Int32'类型。”}
Visual Studio 中的“查找”没有显示 Int64 转换发生的位置。我了解 SQLite 将 Int64 用于标识列,但不知道当 Structs 将其设为 Int32 时 SubSonic 为何/如何处理转换。
帮忙?!
谢谢..
【问题讨论】:
标签: sqlite activerecord subsonic subsonic3