0
我是.NET世界的新手,我試圖從LINQ中獲得一些結果。請幫忙。無法將類型'System.Linq.IQueryable <AnonymousType#1>'隱式轉換爲'System.Collections.Generic.List
以下是我收到的錯誤。
錯誤4不能將類型'System.Linq.IQueryable'隱式轉換爲'System.Collections.Generic.List'。一個顯式轉換存在(是否缺少強制轉換?)..Business \ DAL \ GlobalRequest.cs 39個27個商業
public ObservableCollection<AccountSummary> GetAccountSummary()
{
ObservableCollection<AccountSummary> list;
list = from ListData in
(from a in dbc.Accounts
join b in dbc.Ledgers on a.Account_ID equals b.Account_ID into t2
from t2Data in t2.DefaultIfEmpty()
where a.Is_Mannual == Convert.ToChar("Y")
select new
{
Account_ID = a.Account_ID,
Account_Name = a.Account_Name,
Amount = t2Data.Amount == null ? 0 : t2Data.Amount
}
).OrderBy(item => item.Account_Name)
group ListData by new
{
ListData.Account_ID,
ListData.Account_Name
} into GroupData
select new
{
Account_ID = GroupData.Key.Account_ID,
Account_Name = GroupData.Key.Account_Name,
Amount = GroupData.Sum(OL => OL.Amount)
};
}
class AccountSummary
{
public decimal AccountID { get; set; }
public string AccountName { get; set; }
public decimal Amount { get; set; }
}
請指點。
它工作感謝幫助。偉大的保存 – user2198989 2013-05-04 10:06:17