2015-09-05 63 views
0

我需要一些幫助來弄清楚如何搜索我的SQLite數據庫。 我正在努力尋找他們的蛋糕和星星;這是我的連接:搜索Android C#Xamarin Sqlite數據庫

// Create our connection 
string folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); 
var db = new SQLiteConnection(System.IO.Path.Combine(folder, "OnTopFiles.db")); 
db.CreateTable<User>(); 

// Insert note into the database 
var note = new User { cake = "frosting marble", stars = "5" }; 
db.Insert(note); 

// Show the automatically set ID and message. 
Console.WriteLine("{0}: {1}", note.cake, note.stars); 

回答

0

您可以使用WHERE查詢:

var query = conn.Table<User>().Where(u => u.Cake.StartsWith("frosting")); 
foreach (var user in query) 
{ 
    // Use user.cake or other properties 
} 
0

或者,你可以直接使用SQL。您使用的庫隱藏了SQLite SQL,因此大部分SQLite語法對您都是隱藏的。這個庫是純淨的.NET標準,可在所有Xamarin平臺上運行。您擁有SQL的全部功能,因此搜索與其他平臺相同。

https://github.com/MelbourneDeveloper/SQLite.Net.Standard