0
var AddQuery = from newdist in newSpec.Distributions
where !(from oldDist in oSpec.Distributions
select oldDist.Id).Contains(newdist.Id)
select newdist;
foreach (var dist in AddQuery)
{
dist.operation="Add";
}
var updateQuery = from oldDistributionForUpdate in ospec.Distributions
where (from newDistributionForUpdate in newspec.Distributions
select newDistributionForUpdate.DistributionId).Contains(oldDistributionForUpdate.DistributionId)
&&
(from newDistributionForUpdate in newpaymentSpecification.Distributions
select newDistributionForUpdate.Amount).Equals(oldDistributionForUpdate.Amount)
select oldDistributionForUpdate;
foreach (var dist in updateDistQuery)
{
dist.operation = "Update";
}
를 사용하여 개체를 반복하는 가장 좋은 방법은 무엇입니까?나는 & 과정들을, 내가 뭐하는 거지 달성하는 간단한 방법이 있나요 결과 쿼리 모두에서 개체의 컬렉션을 가질 계획입니다 LINQ
나는 컬렉션을 반복하는 방법이 가장 쉬운 방법이라고 생각합니다. AddQuery.ToList()를 사용할 수 있습니다. ForEach (i => i.operation = "Add")' –