Linq-ToEntities數據源分配在Winforms中掛起

[英]Linq-ToEntities DataSource Assignment Hangs in Winforms


I have a very typical linq-to-entities data binding in WinForms:

我在WinForms中有一個非常典型的linq-to-entities數據綁定:

myGrid.DataSource = myEntities.entity

When it reaches that line of code it simply hangs. Similar assignment a different entity work fine elsewhere in the code. The database contains no more than 50 lines of data in all entities (it's a new project) so it's not waiting on data.

當它到達那行代碼時它就會掛起。類似的賦值不同的實體在代碼中的其他地方工作正常。數據庫在所有實體中包含不超過50行數據(這是一個新項目),因此它不會等待數據。

2 个解决方案

#1


Depending on if it's asp.net or windows forms... If it's a asp.net client you are trying to databind I would recommend sending the results to a List before assigning it to any datasource.

取決於它是asp.net還是windows窗體...如果它是一個asp.net客戶端你正在嘗試數據綁定我建議將結果發送到List,然后再將它分配給任何數據源。

#2


Interestingly, I may have found the solution. I had an entity we'll call C, which linked entities A and B together as a join table. I decided A and B could be linked directly. Apparently this messed up the internal Linq logic and binding to either A or B then hung. When I removed C the binding to A and B started working.

有趣的是,我可能已經找到了解決方案。我有一個實體,我們稱之為C,它將實體A和B連接在一起作為連接表。我決定A和B可以直接鏈接。顯然,這搞砸了內部Linq邏輯並綁定到A或B然后掛起。當我刪除C時,綁定到A和B開始工作。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2009/05/01/72a142f188b98b12f0993941fb3ff4e0.html



 
粤ICP备14056181号  © 2014-2020 ITdaan.com