I'm Creating login form using c#. when I login I get the following error:
LINQ to Entities does not recognize the method 'System.String ToString()' method, and this method cannot be translated into a store expression.**
using (var db = new StageCraftEntities())
{
var isValidUsert = db.Users.Where(i => i.UserName == this.txtUserName.Text.ToString() && i.Password == this.txtPassword.Text.ToString()).FirstOrDefault();
var isValidUser = from User in db.Users
where User.UserName.Equals(this.txtUserName.Text.Trim().ToString())
&& User.Password.Equals(this.txtPassword.Text.Trim().ToString())
select User;
if(true)
{
Dashboard dashboard = new Dashboard(isValidUsert);
dashboard.Show();
this.Hide();
}
}