【发布时间】:2016-07-13 07:37:00
【问题描述】:
我有两个数据表
dtOrder
orderid | trackno | totalamount
----------+--------+------------
1 | test1 | 0
2 | test2 | 0
3 | test3 | 0
4 | test4 | 0
5 | test5 | 0
6 | test6 | 0
7 | test7 | 0
8 | test8 | 0
dtAmounts
id | amount | trackno |
---+----------+--------+
1 | 5 | test1 |
2 | 10 | test2 |
3 | 15 | test1 |
4 | 10 | test4 |
5 | 20 | test1 |
6 | 30 | test6 |
7 | 15 | test4 |
8 | 10 | test6 |
我需要加入并获得基于轨道编号的金额总和,因此生成的数据表应该是:
orderid | trackno | totalamount
----------+--------+------------
1 | test1 | 40
2 | test2 | 10
3 | test3 | 0
4 | test4 | 25
5 | test5 | 0
6 | test6 | 40
7 | test7 | 0
8 | test8 | 0
如何使用 LINQ 和 VB.net 来实现这一点?
【问题讨论】:
标签: c# sql vb.net linq datatable