Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在一个字符串匹配上连接两个表的sql_C#_Sql_Linq - Fatal编程技术网

C# 在一个字符串匹配上连接两个表的sql

C# 在一个字符串匹配上连接两个表的sql,c#,sql,linq,C#,Sql,Linq,这是我的linq查询- from u in db.CardTables join v in db.FunRegistereds on new { u.IsApproved, u.FKCardID } equals new {"YES", v.UserID } 其中,第一个表CardTables中的查询列中有一个字符串匹配,列fkcardd为整数类型 我为这首弦乐比赛感到烦恼 如何将此u.IsApproved列与字符串“YES”匹配,同时以这种方式匹配这两个列???在FKCardID

这是我的linq查询-

from u in db.CardTables
   join v in db.FunRegistereds
   on new { u.IsApproved, u.FKCardID } equals new {"YES", v.UserID }
其中,第一个表
CardTables
中的查询列中有一个字符串匹配,列
fkcardd
为整数类型

我为这首弦乐比赛感到烦恼


如何将此
u.IsApproved
列与字符串
“YES”
匹配,同时以这种方式匹配这两个列???

FKCardID
上加入等于
UserID
并只筛选
u.IsApproved

from u in db.CardTables
join v in db.FunRegistereds
   on u.FKCardID equals v.UserID
where u.IsApproved == "YES"
...

fkcardd
等于
UserID
时加入,只需过滤
u即可

from u in db.CardTables
join v in db.FunRegistereds
   on u.FKCardID equals v.UserID
where u.IsApproved == "YES"
...

您需要为第二个匿名类型初始值设定项中的属性命名:

from u in db.CardTables
join v in db.FunRegistereds
on new { u.IsApproved, u.FKCardID } equals 
   new { IsApproved = "YES", FKCardID = v.UserID }

您需要为第二个匿名类型初始值设定项中的属性命名:

from u in db.CardTables
join v in db.FunRegistereds
on new { u.IsApproved, u.FKCardID } equals 
   new { IsApproved = "YES", FKCardID = v.UserID }

@p、 s.s.w.g谢谢,实际上我在考虑你的解决方案:)但决定不加入查询参数-并添加了过滤:)@p.s.w.g谢谢,实际上我在考虑你的解决方案:)但决定不加入查询参数-并添加了过滤:)