I created a search bar with database connection. When i run it. It get an exception. i use a database that was created before.
Model class entries
public class entries
{
public entries()
{
}
public entries(string word)
{
this.word = word;
}
public entries(string word, string wordtype, string definition)
{
this.word = word;
this.wordtype = wordtype;
this.definition = definition;
}
public string word
{ get; set; }
public string wordtype
{ get; set; }
public string definition
{ get; set; }
public List<string> GetWord { get; set; }
}
Class DatabaseManager:
public class DatabaseManager
{
SQLiteConnection dbConnection;
public DatabaseManager()
{
dbConnection = DependencyService.Get<ISQLite>().GetConnection();
}
public List<string> GetWord()
{
return dbConnection.Query<string>("Select word From [entries]").ToList();
}
}
MainPage.xaml.cs:
DatabaseManager dbManager = new DatabaseManager();
private void MySearchBar_SearchButtonPressed(object sender, EventArgs e)
{
}
private void MySearchBar_TextChanged(object sender, TextChangedEventArgs e)
{
var keyword = MySearchBar.Text;
if(keyword.Length >= 1) {
var suggestions = dbManager.GetWord().Where(c => c.ToLower().Contains(keyword.ToLower()));
SuggestionListView.ItemsSource = suggestions;
SuggestionListView.IsVisible = true;
}
else
{
SuggestionListView.IsVisible = false;
}
}
This is Exception:
System.MissingMethodException: Constructor on type 'System.String' not found.
Please Help. Thank you so much.