使用LINQ连接两个表

RG-*_*G-3 3 c# linq asp.net linq-to-sql

我有两张桌子:

PlanMaster(PlanName,Product_ID)

ProductPoints(Entity_ID,Product_ID,Comm1,Comm2)

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

int getEntity = Int16.Parse(Session["EntitySelected"].ToString());
Run Code Online (Sandbox Code Playgroud)

我想在我的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;
Run Code Online (Sandbox Code Playgroud)

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

无法隐式转换类型'int?' 'bool'

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

Bal*_*a R 13

尝试将其更改为

 where s.Entity_ID == getEntity
Run Code Online (Sandbox Code Playgroud)


Kri*_*nov 7

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;
Run Code Online (Sandbox Code Playgroud)

= 不等于 ==


Jac*_*cob 5

where s.Entity_ID = getEntity应该是where s.Entity_ID == getEntity.