为了账号安全,请及时绑定邮箱和手机立即绑定

谁能提供 linq 查询

谁能提供 linq 查询

C#
慕工程0101907 2021-08-22 15:46:15
现在我想LINQ查询,如果像以下compIds是0001或技术,然后我可以检查与条件divisionCode ,如果compIds是0005或0006则不需要检查与divisionCode这样任何人都可以提供suggetioncompId可能增加取决于需求string[] compID = new string[] { "0002", "0001", "0005", "0006" };string[] divisionCode = new string[] { "01021159", "02013350", "02013483", "02013804", "02013375", "02013374", "02013380", "02013398", "02017379", "02013391", "02013444", "02013353", "02004458", "02013394" };var ACM = (from t1 in Entity.ApprovedContracts          join t2 in Entity.ApprovedResources          on t1.ApprovedResourceId equals t2.ResourceGeneralId          where compID.Contains(t1.OpuCode) && divisionCode.Contains(t1.DivisionCode)          select new          {                t1.OpuCode,                t1.DivisionCode,                t2.EnterpriseId,                t2.ResourceEmail          }).ToList();here
查看完整描述

2 回答

?
白板的微信

TA贡献1883条经验 获得超3个赞

我认为只需要添加更多条件......应该是这样的......


string[] compID = new string[] { "0002", "0001", "0005", "0006" };

string[] divisionCode = new string[] { "01021159", "02013350", "02013483", "02013804", "02013375", "02013374", "02013380", "02013398", "02017379", "02013391", "02013444", "02013353", "02004458", "02013394" };

var ACM = (from t1 in Entity.ApprovedContracts

      join t2 in Entity.ApprovedResources

      on t1.ApprovedResourceId equals t2.ResourceGeneralId

      where compID.Contains(t1.OpuCode) && (t1.OpuCode == "0005" || t1.OpuCode == "0006" || divisionCode.Contains(t1.DivisionCode)

      select new

      {

            t1.OpuCode,

            t1.DivisionCode,

            t2.EnterpriseId,

            t2.ResourceEmail

      }).ToList();


查看完整回答
反对 回复 2021-08-22
  • 2 回答
  • 0 关注
  • 165 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信