C# 谁能提供linq查询
现在我想要一个LINQ查询,如下所示 如果COMPID为0001或0002,则我可以使用分区代码检查条件 如果it compId为0005或0006,则无需检查部门代码,因此任何人都可以提供建议compId可能会根据要求增加C# 谁能提供linq查询,c#,linq,C#,Linq,现在我想要一个LINQ查询,如下所示 如果COMPID为0001或0002,则我可以使用分区代码检查条件 如果it compId为0005或0006,则无需检查部门代码,因此任何人都可以提供建议compId可能会根据要求增加 string[] compID = new string[] { "0002", "0001", "0005", "0006" }; string[] divisionCode = new string[] { "01021159", "02013350", "020134
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
我想只需要再增加一些条件。。。应该是这样的
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();
使用像这样的LINQ:
var orderDates = t1
.Join(t2, _t1 => _t1.Id, _t2 => _t2.Id, (p, o) => new {
t1.OpuCode,
t1.DivisionCode,
t2.EnterpriseId,
t2.ResourceEmail })
.Where(r => r.compID.Contains(t1.OpuCode) >= startDate && r.divisionCode.Contains(t1.DivisionCode)).OrderBy(r => r.OrderDate);
在compId中是否有我们应该检查的模式来决定是否检查分区代码?以及如何检查分区代码?您的问题是没有提供好的信息来帮助我们帮助您,而且您提供的linq中存在什么问题