SaleConfirmationテーブルをクエリして、確認済み/確定済みの購入の概要を取得しようとしていますが、メソッド構文クエリで多くの問題が発生しています。
データベーステーブル
これは、確定した売上を格納するSaleConfirmationテーブル構造です。
Id OfferId ProdId Qty SaleDate
-------------------------------------------------------
10 7 121518 150 2013-03-14 00:00:00.000
19 7 100518 35 2013-03-18 14:46:34.287
20 7 121518 805 2013-03-19 13:03:34.023
21 10 131541 10 2013-03-20 08:34:40.287
- Id:一意の行ID。
- OfferId:オファー/セールテーブルにリンクする外部キー。
- ProdId:製品テーブル内の製品のID。
- 数量:顧客に販売された数量。
- SaleDate:販売が完了した日付。
コントローラのアクション
var confRollUps = db.SaleConfirmation
.GroupBy(c => c.OfferId) // Ensure we get a list of unique/distinct offers
.Select(g => g.Select(i => new {
i.OfferId,
i.Product.Variety, // "Category" of product, will be the same across products for this offer. i.Product is a SQL Server Navigation property.
i.Offer.Price, // The price of the product, set per offer. i.Offer is a SQL Server Navigation property.
i.Offer.Quantity, // The quantity of items that are expected to be sold before the offer expires
i.Offer.DateClose, // Date of when the offer expires
g.Sum(ii => ii.Qty) // Sum up the Qty column, we don't care about ProdIds not matching
}));
選択クエリのエラーはg.Sum(ii => ii.Qty)であり、エラーは以下のとおりです。
匿名タイプのメンバー宣言子が無効です。匿名型のメンバーは、メンバーの割り当て、単純な名前、またはメンバーアクセスを使用して宣言する必要があります。