0
A
回答
3
您很可能會使用SingleOrDefault
或可能Find
。這些方法通過選擇最上面的兩行來工作。然後確保只返回一行。如果返回多個元素,則會拋出異常。
如果有多於一個匹配,它還會怎麼知道?
// If there were two Products with a ProductName of Widget then the code would throw an exception.
context.Products.SingleOrDefault(i => i.ProductName == "Widget");
// If there were two Products with a ProductId of 1234 then the code would throw an exception.
context.Products.Find(1234);
相關問題
- 1. SQL Server選擇頂部
- 2. 掠影顯示新的表單時顯示
- 3. 掠影 - 報道
- 4. 掠影無效
- 5. SQL服務器 - 選擇頂層2行
- 6. 選擇頂部1,最大2場
- 7. 如何在已經選擇的字段中選擇頂部
- 8. 根據在列頂部選擇的選項更改顯示JQchart
- 9. 選擇2顯示默認值選擇
- 10. 顯示頂部2中使用的gremlin
- 11. 在sql表中選擇頂部記錄
- 12. SQL選擇頂部和隨機填充
- 13. 配置具有N層架構的掠影SQL選項卡
- 14. SQL下拉選擇顯示到只有頂部的標題的PHP表格
- 15. 的Microsoft SQL總和值時,選擇SUMA *(選擇頂部1值....)
- 16. 沒有在頂部或底部顯示框陰影
- 17. 同位素:選擇並顯示頂部的.xx類
- 18. jquery日期選擇器顯示在頂部
- 19. 已選擇行顯示在屏幕頂部
- 20. Android:IPhonish選項卡,但顯示在頂部
- 21. 選擇2佔位顯示空選項
- 22. Jquery選擇2未顯示選定值
- 23. SQL排序 - 選擇頂行內的頂部行
- 24. 完全禁用掠影
- 25. SOA架構中的掠影
- 26. Sharepoint的掠影調試器
- 27. 掠影和使用TraceSource
- 28. 中信託中的掠影
- 29. 使選擇框中的選定選項始終顯示在頂部
- 30. 排序和選擇頂部
感謝沒有意識到我們使用的是,我們通常使用FirstOrDefault,但我們的權利,將進一步調查爲什麼。謝謝。並感謝所有其他人爲此付出的努力。 –