Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Linq Pivotting Blues
Message
 
À
Tous
Information générale
Forum:
C#
Catégorie:
LINQ
Titre:
Linq Pivotting Blues
Divers
Thread ID:
01649939
Message ID:
01649939
Vues:
40
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform