我有以下兩個表:亞音速3和LINQ集團通過與伯爵
Customer
{
int Id
int Name
}
Bills
{
int Id
int CustomerId
decimal Amount
bool IsDue
}
現在我試圖讓一個列表,其中我有:
- 一種與每一位客戶進入相關賬單計數。
- 每個客戶的條目與IsDue爲真的相關賬單計數。
我想這樣做的第一個這樣的:
var results = from c in _db.Customers
join b in _db.Bills on c.Id equals b.CustomerId into j1
from j2 in j1
group j2 by c.Id into grouped
select new
{
CustomerId = grouped.Key,
NoOfBills = grouped.Count()
};
這被投擲錯誤: 類型中的表達 'System.Collections.Generic.IEnumerable 1[OutstandingMonitor.MonitorData.Customer]' cannot be used for parameter of type 'System.Linq.IQueryable
1 [OutstandingMonitor.MonitorData.Customer]' ...
請幫我解決這個問題。
此外,這兩個查詢可以結合?
PS:不過使用亞音速3.0.0.3用ActiveRecord
我認爲你指的是LINQ to SQL,他使用的是SubSonic。 –
是的。我正在使用SQLite。有沒有什麼辦法與SubSonic和SQLite產生外鍵關係? – Yogesh
@John - 對,我很抱歉假設LINQ到SQL,儘管我很驚訝類似的東西無法完成。 – Keith