谁能提供 linq 查询

现在我想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


慕工程0101907
浏览 166回答 2
2回答

白板的微信

我认为只需要添加更多条件......应该是这样的......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();
打开App,查看更多内容
随时随地看视频慕课网APP