数据是本地CSV文件,通过OleDB加载到ado.net数据集中.该表有40多个列,包括发票详细信息.每行是发票中的单独行项目,可以包含1到n行.
该查询用于将发票明细分组为每个发票的单行,总计发票金额和到期余额.
以下工作,我正在尝试确定:是否可以在单个查询中执行此操作?
//group the invoices by invoicenumber and sum the total
//Zoho has a separate record (row) for each item in the invoice
//first select the columns we need into an anon array
var invoiceSum =
DSZoho.Tables["Invoices"].AsEnumerable()
.Select (x =>
new {
InvNumber = x["invoice number"],
InvTotal = x["item price"],
Contact = x["customer name"],
InvDate = x["invoice date"],
DueDate = x["due date"],
Balance = x["balance"],
} );
//then group and sum
var invoiceTotals =
invoiceSum
.GroupBy (s => new …Run Code Online (Sandbox Code Playgroud)