예를 들어 설명해 보겠습니다.Linq를 사용하여 누락 된 레코드 조합 확인
var vProducts = new[] {
new { Product = "A", Location ="Y", Month = "January", Demand = 50 },
new { Product = "A", Location ="Y", Month = "February", Demand = 100 },
new { Product = "A", Location ="Y", Month = "March", Demand = 20 },
new { Product = "A", Location ="Y", Month = "June", Demand = 10 }
};
var vPeriods = new[] {
new { Priority = 1, Month = "January" },
new { Priority = 2, Month = "February" },
new { Priority = 3, Month = "March" },
new { Priority = 4, Month = "April" },
new { Priority = 5, Month = "May" },
new { Priority = 6, Month = "June" }
};
var vAll = from p in vProducts
from t in vPeriods
select new
{
Product = p.Product,
Location = p.Location,
Period = t.Priority,
PeriodName = t.Month,
Demand = p.Demand
};
위 쿼리는 제품 & 기간의 모든 조합을 생성합니다. 그러나 아래에 표시된 것과 같이 일치하는 Month가없는 제품과 함께 모든 제품의 목록을 가져와야합니다. 의견에 대한
예를
Product Location Priority Month Demand
A Y 1 January 50
A Y 2 February 100
A Y 3 March 20
A Y 4 April null
A Y 5 May null
A Y 6 June 10
감사합니다.
제목을 조금 더 좋게 만들 수 있습니까? 현재의 질문은 귀하의 질문을 실제로 설명하지 않습니다. –
내가 할 수있는대로 제목을 업데이트하려고 시도했습니다. – user320587