Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Coalescence blues
Message
 
À
14/03/2017 12:11:49
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 5.0
OS:
Windows 8.1
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Divers
Thread ID:
01649038
Message ID:
01649055
Vues:
30
Update : sorry for the confusion, the second linq statement for emWeight is redundant.

Hi Cetan, Naomi. Many thanks for your help.

I had this originally, but it breaks at runtime when there are not EMTransactions (which can happen).
        public static decimal ComputeWeightDifference(int transactionHeaders_Id,PICSEntities context)
        {
            decimal? emWeight = (decimal)context.EMTransactions.Where(r => (r.TransactionHeaders_Id == transactionHeaders_Id)).Sum(r => r.Weight);
            decimal? detailsWeight = 0;
            // emWeight = (decimal?) context.EMTransactions.Where(r => (r.TransactionHeaders_Id == transactionHeaders_Id)).Sum(r => r.Weight) ?? 0;
            detailsWeight = context.TransactionDetails.Where(r => (r.TransactionHeaders_Id == transactionHeaders_Id)).Sum(r => r.Weight);
            return emWeight ?? 0  - detailsWeight ?? 0;
        }
I guess in a "if-you-can't-beat'm-join'm" frame of mind I will split it into the query and the summing. So much for the functional programming fans. :)

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform