I'm trying to select data from Database using SQLiteConnection. It's an UWP application.
public class ResumeModel
{
public List<User> Users { get; set; } = new List<User>();
public ResumeModel()
{
using (var connection = new SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
{
try
{
object query = connection.Query<User>("Select * From User", null);
if(query != null)
{
Users = (List <User>) query;
}
} catch(Exception ex)
{
Debug.Write(ex.ToString());
}
}
}
}
I'm getting the exception: "Object reference not set to an instance of an object"
Here is my User class:
public class User
{
[SQLite.Net.Attributes.PrimaryKey, SQLite.Net.Attributes.AutoIncrement]
public int userID { get; set; }
public String username { get; set; }
public User()
{ }
public User(int userID, string name)
{
this.userID = userID;
this.username = name;
}
}
Does anyone know what I'm doing wrong?
Thanks