加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 使用LINQ连接两个表

发布时间:2020-12-15 20:53:19 所属栏目:百科 来源:网络整理
导读:我有两张桌子: PlanMaster (PlanName,Product_ID) 和 ProductPoints (Entity_ID,Product_ID,Comm1,Comm2) 现在我将Entity_ID存储到一个存储在’int’中的Session中: int getEntity = Int16.Parse(Session["EntitySelected"].ToString()); 我想在我的LINQ查
我有两张桌子:

PlanMaster (PlanName,Product_ID)

ProductPoints (Entity_ID,Product_ID,Comm1,Comm2)

现在我将Entity_ID存储到一个存储在’int’中的Session中:

int getEntity = Int16.Parse(Session["EntitySelected"].ToString());

我想在我的LINQ查询中显示上面表格中的所有项目

Entity_ID = getEntity

这是我的LINQ查询:

var td = from s in cv.Entity_Product_Points join r in dt.PlanMasters on s.Product_ID equals r.Product_ID
         where s.Entity_ID = getEntity
         select s;

现在它给我一个错误,上面写着:

Cannot implicitly convert type ‘int?’ to ‘bool’

这里出了什么问题?感谢您提前的意见!

解决方法

尝试将其更改为

where s.Entity_ID == getEntity

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读