2014-09-12 70 views
0

我正在努力将查询从sql转换为实体linq。我的选择应该是prodhis.stock_units_free总和减去prodhis.stock_units_it总和Entity Linq中两列的总和

任何人都可以指向正确的方向吗?

这是我

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)) 

和不申报错误....

感谢

回答

1

更改您的选择:

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