Problem
In LINQPad 4, when I try to run the following code:
void Main()
{
using (var conn = new SQLiteConnection(@"C:\linqToSqlite"))
{
var query = new SQLiteCommand(conn);
query.CommandText = "SELECT * FROM MyTable";
var result = query.ExecuteQuery<MyTable>();
}
}
I receive the following error:
'System.Data.SQLite.SQLiteCommand' does not contain a definition for 'ExecuteQuery' and no extension method 'ExecuteQuery' accepting a first argument of type 'System.Data.SQLite.SQLiteCommand' could be found (press F4 to add a using directive or assembly reference)
What I have tried
Additional References:
System.Data.Linq.dll
System.Data.SQLite.dll
System.Data.SQLite.Linq.dll
Additional Namespace Imports:
System.Data.Linq
System.Data.SQLite
System.Data.SQLite.Linq // Cannot add this, cleanup removes it.
Thoughts
From MSDN, it seems that ExecuteQuery<T>() is supposed to run on a DataContext and requires the System.Data.Linq namespace from the System.Data.Linq.dll. The above code, ExecuteQuery<T>() is supposed to be running on a SQLiteCommand object instead. Hmm.
Aucun commentaire:
Enregistrer un commentaire