使用LINQ连接两个表



我有两个表:

PlanMaster(PlanName,Product_ID(

ProductPoints(Entity_ID、Product_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?"至"bool">

这里出了什么问题?感谢您提前发表评论!

尝试将其更改为

 where s.Entity_ID == getEntity
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;

=不等于==

where s.Entity_ID = getEntity应为where s.Entity_ID == getEntity

这不是一个双等号吗?

var db1 = (from a in AccYearEntity.OBLHManifests select a).ToList();
var db2 = (from a in MasterEntity.UserMasters select a).ToList();
var query = (from a in db1
             join b in db2 on a.EnteredBy equals b.UserId
             where a.LHManifestNum == LHManifestNum
             select new { LHManifestId = a.LHManifestId, LHManifestNum = a.LHManifestNum, LHManifestDate = a.LHManifestDate, StnCode = a.StnCode, Operatr = b.UserName }).FirstOrDefault();

,我想这就行了

其中s.Entity_ID==getEntity

相关内容

  • 没有找到相关文章

最新更新