Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Coalescence blues
Message
 
To
14/03/2017 12:11:49
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 5.0
OS:
Windows 8.1
Network:
Windows Server 2012 R2
Database:
MS SQL Server
Application:
Desktop
Miscellaneous
Thread ID:
01649038
Message ID:
01649055
Views:
29
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.
Previous
Reply
Map
View

Click here to load this message in the networking platform