【发布时间】:2010-11-01 00:42:44
【问题描述】:
我是 c# 的新手,在将 IList 分配给查询后尝试访问它时遇到问题。这是我的代码:
System.Collections.IList Invoices =
(from p in entities.InvoiceCards
where (p.CustomerCard.ID == CustomerID)
select new
{
InvoiceID = p.ID,
InvoiceDatetime = p.DateTime,
InvoiceTotal = (decimal) p.InvoiceTotal,
}).ToList();
// update the grid
invoiceCardDataGridView.DataSource = Invoices;
----------- 这里编译器在抱怨对象 c?如何在不再次执行查询的情况下访问 IList 中的对象?我需要使用 IList 作为数据源。什么是更好的方法?请附上代码
foreach (var c in Invoices)
InvoiceTotal += (decimal)c.InvoiceTotal;
【问题讨论】:
标签: c#