';和';Linq中的运算符
我有一个查询,当输入username时,它会在label1中打印userid;但我想为用户名和密码编写查询,以打印用户ID。那我怎么写呢?我试着用and运算符写,但似乎不起作用';和';Linq中的运算符,linq,Linq,我有一个查询,当输入username时,它会在label1中打印userid;但我想为用户名和密码编写查询,以打印用户ID。那我怎么写呢?我试着用and运算符写,但似乎不起作用 int id = (from auser in lq.logins where auser.username == userNameString //&& auser.Password =pwdString select auser.userid).SingleOr
int id = (from auser in lq.logins
where auser.username == userNameString //&& auser.Password =pwdString
select auser.userid).SingleOrDefault();
label1.Text = id.ToString();
谢谢
Ani它可能不起作用,因为您使用了
=
而不是=
它可能不起作用,因为您使用了=
而不是=它看起来像是您使用了赋值运算符=
而不是比较运算符=
。查询应为:
int id = (from auser in lq.logins
where auser.username == userNameString && auser.Password == pwdString
select auser.userid).SingleOrDefault();
label1.Text = id.ToString();
看起来您使用了赋值运算符=
,而不是比较运算符=
。查询应为:
int id = (from auser in lq.logins
where auser.username == userNameString && auser.Password == pwdString
select auser.userid).SingleOrDefault();
label1.Text = id.ToString();
你还可以告诉我如何用Linq写inset query吗?@Ani:你一定要读这个:你还可以告诉我如何用Linq写inset query吗。@Ani:你一定要读这个: