使用LINQ我想返回一個包含客戶和發票,他們有一個對象。如何返回多個類作爲IQueryable的<T>
我明白從方法返回一個類型:
public IQueryable<customers> GetCustomers()
{
return from c in customers
select c;
}
,但我有麻煩找出多個對象:
public IQueryable<???> GetCustomersWithInvoices()
{
return from c in customers
from inv in c.invoices
select new {c, ci} // or I may specify columns, but rather not.
}
我有一種感覺,我處理這個錯誤的方式。目標是從控制器調用這些對象,並將它們傳遞給視圖,可以是直接的或使用formViewModel類。
可能重複的[Return anonymous type?](http://stackoverflow.com/questions/534690/return-anonymous-type) – nawfal 2014-06-28 07:38:22