0
返回不正確的數據我一直在使用Oracle的實體框架驅動的ASP.NET Web API的應用程序。我有一個爲視圖定義的實體,如下所示:ASP.NET從OData的控制器
CREATE OR REPLACE FORCE VIEW "PHASE_TWO"."EDIPRODUCT" ("ID", "STK_NUM", "TITLE", "ISBN", "UPC", "ITEMNO", "LONGFORMAT", "ABRIDGED", "WEB_TITLES_ID", "OCLC", "GENRE", "RELYEAR", "ORIG_REL", "LANG", "ORIG_STKNUM", "PUBLISHER", "PEOPLELIST", "SALES_ORG", "NOT_AVAIL") AS
SELECT sap_product.id,
sap_product.stk_num,
sap_product.longdesc AS title,
sap_product.isbn,
sap_product.upc,
sap_product.itemno,
sap_product.longformat,
sap_product.abridged,
mwt_product.web_titles_id,
mwt_product.oclc,
mwt_product.genre,
mwt_product.RELYEAR,
sap_product.orig_rel,
sap_product.lang,
sap_product.orig_stknum,
UPPER (publisher.name) publisher,
(SELECT LISTAGG (p.FULLNAME, ', ') WITHIN GROUP (
ORDER BY pp.rank) AS People
FROM people p
JOIN product_people pp
ON p.id = pp.peopleid
WHERE pp.stk_num = sap_product.stk_num
GROUP BY pp.STK_NUM
) PeopleList,
sppg.PRICING_TYPE as sales_org,
sap_product.not_avail
FROM sap_product
JOIN mwt_product ON sap_product.stk_num = mwt_product.stk_num
JOIN publisher ON mwt_product.publisherid = publisher.id
JOIN SAP_PRODUCT_PRICING_GROUP sppg on sppg.STK_NUM = mwt_product.stk_num and sppg.MARKED_FOR_DELETION = 0
WHERE mwt_product.WEB_PRODUCTS_ID > 0;
此視圖在SQL Developer中按預期工作。在我的控制器我getEDIPRODUCT功能(是的,這是VB.NET)如下:
' GET: odata/EDIPRODUCTs
<EnableQuery>
Function GetEDIPRODUCT() As IQueryable(Of EDIPRODUCT)
Dim results As IQueryable
results = db.EDIPRODUCT
For Each _product In results
Console.Write(_product)
Next
Return results
End Function
我剛添加的對以循環檢查的結果。我查看結果時看到的是每行返回相同的產品記錄。爲ID的值是重複的,並且應該具有變體值的唯一其他字段(如sppg.PRICING_TYPE sales_org)也只是重複。
我有這個地方不發生其他意見。正確的記錄數總是返回,但檢索到的第一個記錄是始終只是重複的結果集的每一排。任何想法可能會發生在這裏?
你有沒有複製並粘貼到創建這個?如果是這樣,很可能您錯過了查詢中的一個或多個更改。 –
我不確定你的意思。我在這裏粘貼了查詢,但使用設計器將視圖添加到模型中,並且是最新的。 –