我有以下設置:LINQ到實體連接查詢
表ShoeAreas
有列ShoeId
和MaterialId
。 表Shoes
具有列ID
和Status
。
我有一個方法需要一個參數 - materialId
,目標是確定ShoeAreas
中是否有記錄,其中MaterialId
等於像參數那樣傳遞的記錄。並且如果這樣的記錄(或者最有可能的記錄)存在,如果它們相信從Shoes with
狀態'=生產'。
我嘗試這樣做:
return shoeService.All().
Join(shoeAreaService.All(),
s => s.ID,
sa => sa.ShoeId,
(s, sa) => (sa.MaterialId == matId)).
Any(s => (s.Status == (byte)EntityStatusProd.Production)));
但我得到了Any..
行錯誤說} expected
,也這是我第二次LINQ到實體查詢我寫的,所以我懷疑,如果是語法問題或查詢自己錯了。
有適當的實體,您應該能夠使用導航屬性,而不是加入的。 – MarcinJuraszek 2013-04-10 07:01:13