我需要像这样加入两个表
var quer = from i in tableB
join s in tableA on i.Code.Split('-').FirstOrDefault() equals s.Code
select new { i, s };
这是我的疑问。
public static double sum2d(double[][] theSum) {
double total2 = 0;
for (int row = 0; row < theSum.length; row++) {
for (int col = 0; col < theSum[row].length; col++){
total2 = total2 + theSum[row][col];
}
}
return total2;
}
但这不起作用......
我该怎么做?
答案 0 :(得分:2)
var query = from i in tableB
from s in tableA
where i.Code.StartsWith(s.Code)
select new { i, s };
答案 1 :(得分:0)
我会尝试:
var query = TableA.Join(TableB,
a => a.Code.Split('-').FirstOrDefault(),
b => b.SiteCode,
(a, b) => new { a = a, b = b });
答案 2 :(得分:0)
试试这段代码它会对你有所帮助。但要确保第一个值不能为空。
var quer = from i in tableB
join s in tableA on i.Code.Split('-')[0] equals s.Code
select new { i, s };