2015-09-05 58 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