我在这里加入2个DataTables进行群组总结。从这个查询中,我可以检索组中的列,即代码,子代码 - > sum1,但我不仅需要组中的列,还需要来自表[c.glaccount,j.type in select new]中的其他coulmns,这可以从SQL查询中获得。
var currentbalances = (from c in _currentPeriodTaxBalanceTable.AsEnumerable()
join j in dtAcsTaxCode.AsEnumerable() on
c.Field<int>(TaxCodeNGLAccountEntity.GLAccountKey) equals
j.Field<int>(TaxCodeNGLAccountEntity.GLAccountKey)
// enter code here
group c by new {code = j.Field<string>("tax_code"), subcode = j.Field<string>("tax_subcode")}
into sum1
select new {balance = sum1.Sum(c => c.Field<decimal>("balance_amount"))}
);