私のコードでは、Invoices
の集約番号InvoiceLine
の合計と、それぞれInvoice
に関連付けられたTracks
のリストを取得したいと考えています。グループ化された要素のSelectMany
var screenset =
from invs in context.Invoices
join lines in context.InvoiceLines on invs.InvoiceId equals lines.InvoiceId
join tracks in context.Tracks on lines.TrackId equals tracks.TrackId
group new { invs, lines, tracks }
by new
{
invs.InvoiceId,
invs.InvoiceDate,
invs.CustomerId,
invs.Customer.LastName,
invs.Customer.FirstName
} into grp
select new
{
InvoiceId = grp.Key.InvoiceId,
InvoiceDate = grp.Key.InvoiceDate,
CustomerId = grp.Key.CustomerId,
CustomerLastName = grp.Key.LastName,
CustomerFirstName = grp.Key.FirstName,
CustomerFullName = grp.Key.LastName + ", " + grp.Key.FirstName,
TotalQty = grp.Sum(l => l.lines.Quantity),
TotalPrice = grp.Sum(l => l.lines.UnitPrice),
Tracks = grp.SelectMany(t => t.tracks)
};
しかし、最後の行で、私はSelectManyは私にエラーを与えているんでした:
Tracks = grp.SelectMany(t => t.tracks)
エラー:
The type arguments cannot be inferred from the usage. Try specifying the type arguments explicitly.
任意のアイデアはなぜですか?
ありがとうございます。
たぶん、[この質問](http://stackoverflow.com/questions/3917249/the-type-arguments-for-method-cannot-be-inferred使い方から)はあなたにも答えます。 – meJustAndrew