5
SaleConfirmation 테이블을 쿼리하여 확인 된/최종 구매 요약을 얻으려고하고 있지만 메서드 구문 쿼리에 많은 어려움이 있습니다.Entity Framework 5 메서드 쿼리 롤업
데이터베이스 테이블 여기
는 매장 판매를 완결 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 : Offer/Sale 테이블에 연결된 외부 키입니다.
- 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)이고 오차 이하이다.
유효하지 않은 익명 형식 멤버 선언자가 있습니다. 익명 형 멤버는 으로 멤버 할당, 단순한 이름 또는 멤버 액세스로 선언해야합니다.