3
상당히 간단한 요구 사항이있는 것 같지만 주위를 둘러 보니 간단한 대답을 얻을 수 없습니다. 나는 MSDN 포럼, ExperExchange를 살펴 보았고 나에게 많은 것을주지 않았다.조건부 그룹 By 문 LINQ를 사용하여
나는 다음과 같은 LINQ 코드 내가 RevLevel
및 SAPLocation
에 의한 조건부 그룹에 수 있어야합니다
Dim SummaryLog As IQueryable(Of clPartCountSummary)
SummaryLog = From Inventory In db.tblPartCounts _
Where Inventory.InventoryCountId = InventoryCountId _
And Not Inventory.ActionId.HasValue _
Group By PartNumber = Inventory.PartNumber _
, Inventory.RevLevel, SAPLocation = Inventory.SAPLocation _
Into AggregatedProdLog = Group, Qty = Sum(Inventory.Quantity) _
Select New clPartCountSummary With
{.PartNumber = PartNumber,
.RevLevel = RevLevel,
.Qty = Qty,
.SAPLocation = SAPLocation}
에게 있습니다. 나는 항상 PartNumber
으로 그룹화 할 것이지만, 나머지 두 개는 선택 사항입니다. 따라서 변수 bRevLevel
이 true이면 RevLevel
으로 그룹화하고 bSAPLocation
이 참인 경우 SAPLocation
으로 그룹화합니다.
도움이 될 것입니다. 여러 단계의 SummaryLog
정의가 매력적으로 보이기 시작했습니다.
감사합니다, 토마스이 도움이