dave
dave

Reputation: 1430

Sum of two columns in Entity Linq

I am struggling to translate a query from sql to entity linq. My select should be the Sum of prodhis.stock_units_free minus the Sum of prodhis.stock_units_it

can anyone point me in the right direction?

This is what I have

Dim res As Integer = (From it In rmis.product_detail Join prodhis In rmis.PRODUCT_HISTORY On it.SKU_ID Equals prodhis.SKU_ID _
                         Where prodhis.WEEK_SELECTOR = cws AndAlso
                         it.POS_CODE = ItemID AndAlso
                         prodhis.BRANCH_ID = 23
                         'Stuck Here:
Select (sum(prodhis.STOCK_UNITS_FREE) - sum(prodhis.STOCK_UNITS_IT))

Sum is not declared error....

Thanks

Upvotes: 0

Views: 503

Answers (1)

Aducci
Aducci

Reputation: 26664

Change your select to:

Select prodhis.STOCK_UNITS_FREE - prodhis.STOCK_UNITS_IT).Sum();

Upvotes: 1

Related Questions