【发布时间】:2015-04-13 23:55:22
【问题描述】:
问题
在 LINQPad 4 中,当我尝试运行以下代码时:
void Main()
{
using (var conn = new SQLiteConnection(@"C:\linqToSqlite"))
{
var query = new SQLiteCommand(conn);
query.CommandText = "SELECT * FROM MyTable";
var result = query.ExecuteQuery<MyTable>();
}
}
我收到以下错误:
“System.Data.SQLite.SQLiteCommand”不包含“ExecuteQuery”的定义,并且找不到接受“System.Data.SQLite.SQLiteCommand”类型的第一个参数的扩展方法“ExecuteQuery”(按 F4 到添加 using 指令或程序集引用)
我尝试过的
其他参考:
System.Data.Linq.dll
System.Data.SQLite.dll
System.Data.SQLite.Linq.dll
其他命名空间导入:
System.Data.Linq
System.Data.SQLite
System.Data.SQLite.Linq // Cannot add this, cleanup removes it.
I've also found documentation,其中谈到了使用SQLiteCommand.ExecuteQuery 方法。这是我唯一看到提到的命令的地方。
【问题讨论】:
-
如果我记得清楚的话,我认为SQLLiteCommand不支持这种方法。也许你应该考虑使用 Linq 的 SqlLiteDataContent 的 ExecuteQuery
() -
@ProgrammingFan 我们在哪个程序集中找到
SqlLiteDataContext及其ExecuteQuery<T>()方法?