I've got a method for my xamarin android app that checks a sqlite db for login credentials. I'm fairly new to async tasks and was wondering how to change the method below to an async method.
I know I can change the call to the method easily enough with await and changing the calling method to an async relay command but how do I change the query method?
public static bool CheckLogin(string userName, string password)
{
bool valid = false;
string dbPath = Path.Combine(documentsPath, "..", dbName);
using (var conn = new SQLite.SQLiteConnection(dbPath))
{
try {
var command = conn.CreateCommand("select * from tblUsers where nLogin = ? and nPassword = ?", userName, password);
//currentUser = command.ExecuteScalar<User>();
var user = conn.Query<User>("select * from tblUsers where nLogin = ? and nPassword = ?", userName, password);
if (user.Count>0)
{
valid = true;
}
}
catch(Exception ex)
{
throw ex;
}
}
return valid;
}
Any help would be appreciated.
Aucun commentaire:
Enregistrer un commentaire