使用 LINQ 连接两个表
我有两张桌子:
PlanMaster(计划名称、产品 ID)
和
产品点(Entity_ID、产品_ID、Comm1、Comm2)
现在我将 Entity_ID 存储到一个存储在“int”中的会话中:
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;
现在它给了我一个错误,内容如下:
无法隐式转换类型“int”? '布尔'
这里出了什么问题?感谢您提前提出意见!
I have two tables:
PlanMaster (PlanName, Product_ID)
and
ProductPoints (Entity_ID, Product_ID, Comm1, Comm2)
Now I am storing Entity_ID into a Session which is stored into an 'int':
int getEntity = Int16.Parse(Session["EntitySelected"].ToString());
I want to show in my LINQ query all of the items from above tables which has
Entity_ID = getEntity
Here is my LINQ query:
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;
Now its giving me an error which says:
Cannot implicitly convert type 'int?' to 'bool'
What is going wrong here? Thank you for your comments in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
尝试将其更改为
Try changing it to
=
不等于==
=
not equal to==
where s.Entity_ID = getEntity
应该是where s.Entity_ID == getEntity
。where s.Entity_ID = getEntity
should bewhere s.Entity_ID == getEntity
.不应该是双等号吗?
Shouldn't that be a double equals?
我认为这样就可以了,
其中 s.Entity_ID == getEntity
I think this will do,
where s.Entity_ID == getEntity