I am trying to write a generic method to get the data from tables.
I am using sqlite-net ORM.
My methods compile well for delete:
public bool DeleteItem<T>(T NewItem)
{
SQLiteConnection conn = new SQLiteConnection(GetConnection());
var result = conn.Delete<T>(NewItem);
//...
}
And
public void CreateTable<T>()
{
SQLiteConnection conn = new SQLiteConnection(GetConnection());
conn.CreateTable<T>();
conn.Close();
}
But if I try to get Table data as list, I get a compile error at conn.Table:
T Must be a non-Abstract Type ....
Here is my code that does not want to compile:
public List<T> GetAllItems<T>(string SelTable)
{
SQLiteConnection conn = new SQLiteConnection(GetConnection());
List<T> MyItems = conn.Table<T>().ToList();
conn.Close();
return MyItems;
}