OK - So I'm still new to all this EF and Telerik stuff. However after doing research I'm sure it's not a Telerik control issue. In any case, I thought I would start here for help.
I have a simple Entity relationship (Lot_head and Lot_Detail)
When I execut the following code:
The grid populates the data correctly, however when I scroll to the end of a row, it throws the "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." exception.
Now I understand that since I am using lazing loading and using the 'Using' statement, the context has been disposed. I'm also assuming that the datagrid must rely on having that context left open. As many have mentioned you should keep the context open for only as long as you need it. If that's the case, how would you write this example?
Thanks for the help!
Bob
I have a simple Entity relationship (Lot_head and Lot_Detail)
When I execut the following code:
Private
Sub
btnSearchPO_Click(sender
As
System.
Object
, e
As
System.EventArgs)
Handles
btnSearchPO.Click
LotDetailsDataGrid.DataSource = getLotDetails(PurchaseOrderTextBox.Text)
End
Sub
Private
Function
getLotDetails(lotNumber
As
Integer
)
As
List(Of Lot_Detail)
Using context
As
New
Three_Way_MatchEntities
Dim
lot = (From ld
In
context.Lot_Detail
Where (ld.Lot_Number = lotNumber)
Select
ld).ToList
Return
lot
End
Using
End
Function
The grid populates the data correctly, however when I scroll to the end of a row, it throws the "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection." exception.
Now I understand that since I am using lazing loading and using the 'Using' statement, the context has been disposed. I'm also assuming that the datagrid must rely on having that context left open. As many have mentioned you should keep the context open for only as long as you need it. If that's the case, how would you write this example?
Thanks for the help!
Bob