vendredi 30 octobre 2015

Windows Phone 8.1 Sqlite select Query result error

I am using Windows Universal app project. I want to compare the result return by the select statement but giving me a error.

private async void btnLogin_Click(object sender, RoutedEventArgs e)
    {
        string input = txtMobNo.Text;
        SQLiteAsyncConnection connection = new SQLiteAsyncConnection("People.db");
        var queryVar = connection.Table<User>().Where(x => x.userMbNo.StartsWith(input));

        var queryResult = await queryVar.ToListAsync();


        if (queryResult==0)
        {
            string msg = "Login Failed : Invalid ID or Password";
            MessageDialog dialog = new MessageDialog(msg);
            await dialog.ShowAsync();
        }
        else
        {
            string msg = "User Found";
            MessageDialog dialog = new MessageDialog(msg);
            await dialog.ShowAsync();
        }

    }

Result return by queryresult is in List type how can I compare the results. I want to find the user exist in database or not.

[Table("Users")]
public sealed class User
{
    [PrimaryKey]
    public string userMbNo { get; set; }
    public string userName { get; set; }
    public string userPassword { get; set; }

    public User()
    {

    }

    public User(string usrMbNo,string usrName, string usrPwd)
    {
        userMbNo = usrMbNo;
        userName = usrName;
        userPassword = usrPwd;
    }

Aucun commentaire:

Enregistrer un commentaire