I have what seems to be a fairly simple requirement, but looking around I'm not able to get a simple answer for this. I have looked on MSDN forums, Exper Exchange and nothing substantial was given to me.
I have the following LINQ code
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}
I want to be able to conditionally group by on RevLevel
and SAPLocation
. I will always group by PartNumber
, but the other two are optional. So if a variable bRevLevel
is true then we group by RevLevel
and if bSAPLocation
is true then we group by SAPLocation
as well.
Any help will be much appreciated, I'm at the stage where multiple SummaryLog
definitions are starting to look appealing.
Thanks, Tomasz