2
これはLINQで可能ですか?フィールド(LineTotal)でグループ化し、上位9個のグループのみを返し、次に10番目のグループで合計他のすべてのグループの? SQL ServerでLinqは10番目のグループとして上位9個のグループと他のすべてのグループの合計を取得します
これがそうのように行うことができます。
with TopGroups as
(
select sum(sol.LineTotal) as ProductGroupSales, p.ProductGroupId,
ROW_NUMBER() OVER(ORDER BY sum(sol.LineTotal) DESC) as Num
from SalesOrderLines sol left join Products p on p.Id = sol.ProductId
group by p.ProductGroupId
)
select ProductGroupSales from TopGroups where Num < 10
union all
select sum(ProductGroupSales) from TopGroups where Num >= 10
が、これはLINQに翻訳することはできますか? ROW_NUMBER() OVER()
とunion all
はどのようにLINQに変換されるのか分かりません。
上記のSQLステートメントは、この質問の答えに触発されました。http://stackoverflow.com/a/2601130/325727 –