Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Linq Pivotting Blues
Message
 
To
All
General information
Forum:
C#
Category:
LINQ
Title:
Linq Pivotting Blues
Miscellaneous
Thread ID:
01649939
Message ID:
01649939
Views:
39
Close, but no cigar.
                          using (var context = new PICSEntities(Config.model.SqlServer))
            {
                var q = context.TransactionDetails.Where(t => t.Parcel.GoodsType.Description == "Rough")
                    .Where(t => t.Parcel.ParcelInventoryType.Description == "" +
                    "Inventory")
                    .GroupBy(t => new { f1 = t.Parcel.RSReference /*, f2 = t.TransactionHeader.TransactionType.Description */ }, (key, g) =>
                      new
                      {
                          Parcel = key.f1,
                          BeginningInventory = g.Where(x => x.TransactionHeader.TransactionType.Description == "Beginning Inventory").Select(x => x.Cogs),
                          Purchase = g.Where(x => x.TransactionHeader.TransactionType.Description == "Purchase").Select(x => x.Cogs),
                          Transfer = g.Where(x => x.TransactionHeader.TransactionType.Description == "Internal Transfer").Select(x => x.Cogs),
                          Sale = g.Where(x => x.TransactionHeader.TransactionType.Description == "Sale").Select(x => x.Cogs)
                      });
For the avoidance of doubt, I'm trying to get a table consisting of a line for each Parcel and the total Cogs for each TransactionType (Beginning Inventory, Purchase, Transfer and Sale on the same line but in a different column. It seem to put a collection in each cell where I was hoping to get the Cogs.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Next
Reply
Map
View

Click here to load this message in the networking platform