2
我想轉換一些舊的代碼爲Windows 8使用SQLite。以下是來自以前會話的代碼。SQLite和列表通用C#
using (SqliteConnection conn = new SqliteConnection("Version=3,uri=file://flashcards0904.db"))
{
conn.Open();
using (SqliteCommand cmd = conn.CreateCommand())
{
cmd.CommandText = "SELECT * FROM Decks where DeckGroup='" + Global.currentDeckGroup.ToString() + Global.currentDeck.ToString() + "'" + "order by random()";
List<string> myCollection = new List<string>();
using (SqliteDataReader reader = cmd.ExecuteReader())
{
while (reader.Read())
{
myCollection.Add(reader.GetString(0) + "~" + reader.GetString(1) + "~" + reader.GetString(2));
Global.words = myCollection.ToArray();
}
}
conn.Close();
Community.CsharpSqlite.FileStream.HandleTracker.Clear();
}
}
現在,我沒有獲得SqliteDataReader,我試圖用一個列表<>的功能,但我不能讓「去哪兒」條款的工作。任何幫助,這裏是我目前的代碼:
var root = Windows.Storage.ApplicationData.Current.LocalFolderPath;
var dbPath= Path.Combine(Windows.Storage.ApplicationData.Current.LocalFolderPath,"flashcards0904.db");
using(var db= new SQLite.SQLiteConnection(dbPath))
{
// Here is location for the missing Where Clause"
var list= db.Table<Decks>.Where??????? .ToList();
}
希望這可以解釋這個問題。
感謝
原來的查詢中使用'「爲了通過隨機()」'也被洗牌甲板 –
你說得對,我他不確定他是否想要那部分的幫助。這裏有一個明確的例子:http://stackoverflow.com/questions/3339192/linq-orderby-random – JoshVarty
優秀的迴應,Mucho謝謝 –