I'm newbie to c# and i have problem trying to access IList after i assign it to the query. Here is my code:
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;
----------- Here the compiler is complaining about object c? how can I access the objects in the IList without executing the query again? I need to use IList to use as a datasource. what is a better way? Please include the code
foreach (var c in Invoices)
InvoiceTotal += (decimal)c.InvoiceTotal;