'And' operator in Linq
I have a query that prints userid in label1 when username is entered.Works fine; but i want to write query for username and password that prints userid. so how can i write it? i tried writing using 'and' operator but dont seems to work.
int id = (from auser in lq.logins
where auser.username == user开发者_运维知识库NameString //&& auser.Password =pwdString
select auser.userid).SingleOrDefault();
label1.Text = id.ToString();
Thanks Ani
It looks like you used the assignment operator =
instead of the comparison operator ==
. The query should be:
int id = (from auser in lq.logins
where auser.username == userNameString && auser.Password == pwdString
select auser.userid).SingleOrDefault();
label1.Text = id.ToString();
It probably doesn't work becase you used =
instead of ==
.
精彩评论