2013-10-09 46 views
0

我在我的應用程序中使用SQLite(WP 7.1和Community.CsharpSqlite.SqlLiteClient.WP7.dll程序集)。什麼是最好的WP7:SQLite或Data.Linq?

當我使用內部聯接(大約3到5秒來填充1000個記錄的列表)時,SQLite DataReader對象非常慢。

我在考慮刪除SQLite數據庫並開始使用「sdf」數據庫。

有誰知道爲什麼SQLite DataReader對象在WP中太慢了嗎?

這裏是我的示例代碼(table1is表5000個記錄和5列。表2還chield從表1的記錄)

using (SqliteConnection conn = new SqliteConnection(PhoneUtil.ConnectionString)) 
{ 
    conn.Open(); 
    using (SqliteCommand cmd = conn.CreateCommand()) 
    { 
     cmd.CommandText = "select t1.* from table1 as t1 inner join table2 as t2 on t1.id = t2.id where t1.year=2013"; 

     // the line below is very slow. 
     using (SqliteDataReader reader = cmd.ExecuteReader()) 
     { 
     // Here is fast 
     while (reader.Read()) 
     { 
      // ... 
     } 
     } 
    } 
} 
+0

你有沒有索引的表? –

+0

如果我直接在數據庫上運行查詢,我會很快得到結果。問題是當我從應用程序運行。而且,這個問題只發生在ExecuteReader()方法中。 –

+0

ExecuteReader _may_在返回第一個結果之前讀取整個結果,如果結果很大,可能需要一段時間。 SQLite shell(據我記憶)立即返回第一個找到的值。 –

回答

0

,對於WP7 SQLite的實現是完全託管的事實代碼可能至少部分原因。

相關問題